%lo(), %hi(), and %pcrel_hi() are supported and test cases have been added to ensure the appropriate fixups and relocations are generated. I've added an instruction format field which is used in RISCVMCCodeEmitter to, for instance, tell whether it should emit a lo12_i fixup or a lo12_s fixup (RISC-V has two 12-bit immediate encodings depending on the instruction type).
Additionally, fixups and relocations in jal and branch instructions are supported.
I actually tried a couple ways of handling this and decided that introspecting the instruction format in RISCVMCCodeEmitter ended up cleanest. I'd be happy to hear any other suggestions though.
This completes the first batch of patches.
I think this is problematic, fixup_riscv_lo12_i is only used for S instruction format in RISCV. I think this should be
if (MIFrom == RISCVII::InstFormatI) {
} else if (RISCVII::InstFormatS) {
FixUpKind = RISCV::fixup_riscv_lo12_s;
} else {
}
Other wise you'll mistakenly end up generating instructions instructions with wrong fixup kinds!