[SystemZ] Allow symbols in immediate asm operands
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 20 Jul 2023 08:11:24 +0000 (10:11 +0200)
committerIlya Leoshkevich <iii@linux.ibm.com>
Fri, 21 Jul 2023 09:09:19 +0000 (11:09 +0200)
commita0eee6c971878b1f2edcc34fb2513e12a04a29ba
tree04e5c801545c229b2b881acc771619bde8acf9b0
parente6c62a2dcc8c12df2c94397e9f4537f45e32f230
[SystemZ] Allow symbols in immediate asm operands

Currently mentioning any symbols in immediate asm operands is not
supported, for example:

    error: invalid operand for instruction
    lghi %r4,foo_end-foo

The immediate problem is that is*Imm() and print*Operand() functions do
not accept MCExprs, but simply relaxing these checks is not enough:
after symbol addresses are computed, range checks need to run against
resolved values.

Add a number of SystemZ::FixupKind members for each kind of immediate
value and process them in SystemZMCAsmBackend::applyFixup(). Only
perform the range checks, do not change anything.

Adjust the tests: move previously failing cases like the one shown
above out of insn-bad.s.

Reviewed By: uweigand

Differential Revision: https://reviews.llvm.org/D154899
14 files changed:
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCFixups.h
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCObjectWriter.cpp
llvm/lib/Target/SystemZ/SystemZOperands.td
llvm/test/MC/SystemZ/fixups-bad-z13.s [new file with mode: 0644]
llvm/test/MC/SystemZ/fixups.s
llvm/test/MC/SystemZ/insn-bad-z196.s
llvm/test/MC/SystemZ/insn-bad.s
llvm/test/MC/SystemZ/insn-good-z196.s
llvm/test/MC/SystemZ/insn-good.s
llvm/test/MC/SystemZ/reloc-absolute.s