[LoongArch] Add support for the BranchRelaxation pass
authorXiaodong Liu <liuxiaodong@loongson.cn>
Wed, 2 Nov 2022 07:47:26 +0000 (15:47 +0800)
committerXiaodong Liu <liuxiaodong@loongson.cn>
Tue, 8 Nov 2022 11:26:16 +0000 (19:26 +0800)
commit57ad3f1dc63890c96e9c1565489e1da65b0fb032
tree355dbf5d7ffadd3dd434d4bac5400b88bbf789e4
parent5426a1e51d20a13f575ae03c10b274430b4a3539
[LoongArch] Add support for the BranchRelaxation pass

When the branch target is out of the range represented by the current
branch instruction's immediate, branch relaxation is required. There
are three types of immediate for branch instructions on LoongArch,
including simm16, simm21 and simm26. And the real branch target
address is PC + sext(simmXX << 2). In addition, the indirect branch
way is implemented to support larger branch target.

BranchRelaxation pass calls `RenumberBlocks` to renumber all of the
machine basic blocks in the function. So the machine basic blocks
number changed in some test cases.

Differential Revision: https://reviews.llvm.org/D137233
llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
llvm/test/CodeGen/LoongArch/analyze-branch.ll
llvm/test/CodeGen/LoongArch/branch-relaxation.ll [new file with mode: 0644]
llvm/test/CodeGen/LoongArch/exception-pointer-register.ll
llvm/test/CodeGen/LoongArch/jump-table.ll
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/loongarch_generated_funcs.ll.generated.expected
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/loongarch_generated_funcs.ll.nogenerated.expected