OSDN Git Service

[RISCV] Support .option relax and .option norelax
authorAlex Bradbury <asb@lowrisc.org>
Mon, 12 Nov 2018 14:25:07 +0000 (14:25 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Mon, 12 Nov 2018 14:25:07 +0000 (14:25 +0000)
commitc90bfa871556b02a175237404519fb4667d6e7c3
tree56e4ed9b441db38e7e5eb341a70a32b40f42c72c
parentc5dba22c1dbe70b0248125dfcb0b68406475f6c4
[RISCV] Support .option relax and .option norelax

This extends the .option support from D45864 to enable/disable the relax
feature flag from D44886

During parsing of the relax/norelax directives, the RISCV::FeatureRelax
feature bits of the SubtargetInfo stored in the AsmParser are updated
appropriately to reflect whether relaxation is currently enabled in the
parser. When an instruction is parsed, the parser checks if relaxation is
currently enabled and if so, gets a handle to the AsmBackend and sets the
ForceRelocs flag. The AsmBackend uses a combination of the original
RISCV::FeatureRelax feature bits set by e.g -mattr=+/-relax and the
ForceRelocs flag to determine whether to emit relocations for symbol and
branch diffs. Diff relocations should therefore only not be emitted if the
relax flag was not set on the command line and no instruction was ever parsed
in a section with relaxation enabled to ensure correct diffs are emitted.

Differential Revision: https://reviews.llvm.org/D46423
Patch by Lewis Revill.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346655 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h [new file with mode: 0644]
lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
test/CodeGen/RISCV/fixups-relax-diff.ll [new file with mode: 0644]
test/CodeGen/RISCV/option-norelax.ll [new file with mode: 0644]
test/CodeGen/RISCV/option-relax.ll [new file with mode: 0644]
test/MC/RISCV/option-invalid.s
test/MC/RISCV/option-relax.s [new file with mode: 0644]