Support .option rvc and norvc to enable/disable C extension within file.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/MC/RISCV/option-rvc.s | ||
---|---|---|
22 ↗ | (On Diff #143232) | Kito, can you add an instruction before the first .option rvc to make sure the default behavior is unaltered: |
test/MC/RISCV/option-rvc.s | ||
---|---|---|
29 ↗ | (On Diff #143232) | and add more than one instruction in an option block to show it compresses or not all of instructions in the block. |
lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h | ||
---|---|---|
21 ↗ | (On Diff #143232) | This should be pure virtual method that you only implement in your RISCVTsargetELFstreamer and your RISCVASMstreamer. Making it virtual causes extra entries for your vtable. Look at MCStreamer.h line 62 |
Changes:
- Fix coding style issue.
- Add more instructions to testcase.
- Make emitDirectiveOptionRVC and emitDirectiveOptionNoRVC to pure virtual function.
- Return nullptr rather than RISCVTargetStreamer in createRISCVObjectTargetStreamer, because we have pure virtual function in RISCVTargetStreamer now.
Thanks Kito. Could you please add some tests for the new warning/failure cases introduced by this patch? e.g. .option with unrecognised identifier etc.
lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp | ||
---|---|---|
98–99 ↗ | (On Diff #143682) | Unnecessary comment - the function call is pretty self-descriptive. |
Thanks for adding the test case, this looks good to me now. Final nit: could youplease get rid of the unnecessary comment for RegisterAsmTargetStreamer (https://reviews.llvm.org/D45864#inline-403118)?
There's a corner case we're probably going to encounter here vs gcc.
In GCC, .option rvc or .option norvc in inline asm will have the effect of enabling/disabling instruction compression from that point onwards. I assume it won't have that effect with LLVM unless you use -save-temps. It might be that we decide this use of inline asm isn't supported by LLVM and people should use appropriate function or module attributes instead. Either way, a test which demonstrates the behaviour would be worthwhile.
Changes:
- Add 2 test cases to show .option rvc and .option norvc in inline asm will not effect the code gen.
Thanks Kito! I'll add a comment to the test/CodeGen/RISCV files when committing just to indicate their purpose.