[PATCH] D154899: [SystemZ] Allow symbols in immediate asm operands

Ilya Leoshkevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 14:57:13 PDT 2023


iii created this revision.
iii added a reviewer: uweigand.
Herald added a subscriber: hiraditya.
Herald added a project: All.
iii requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.

In order to create fixups, one needs to know the operand offsets.
Unfortunately the existing LLVM infrastructure does not provide this
information. Implement generating getOperandBitOffset(), which provides
this information. It does not return useful values for multi-lit
operands, such as SystemZ vector registers, but this is not important
for its intended use case.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154899

Files:
  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/SystemZOperands.td
  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/utils/TableGen/CodeEmitterGen.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154899.538843.patch
Type: text/x-patch
Size: 29802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230710/02ac2dd7/attachment-0001.bin>


More information about the llvm-commits mailing list