diff options
author | wanglei <wanglei@loongson.cn> | 2022-11-10 20:28:23 +0800 |
---|---|---|
committer | wanglei <wanglei@loongson.cn> | 2022-11-10 20:53:20 +0800 |
commit | 0436cf5f52175a2a97d4cf2ff30fac54df7645b5 (patch) | |
tree | 6cb4067e02588919b6aab977c074928e7f8c5335 /llvm/lib/Target/LoongArch | |
parent | 926acd2bb55d8deed96b134a12321ee6725671f4 (diff) | |
download | llvm-0436cf5f52175a2a97d4cf2ff30fac54df7645b5.zip llvm-0436cf5f52175a2a97d4cf2ff30fac54df7645b5.tar.gz llvm-0436cf5f52175a2a97d4cf2ff30fac54df7645b5.tar.bz2 |
[LoongArch] Support parsing target specific flags for MIR
These hooks ensure that the LoongArch backend can serialize and parse
MIR correctly.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D137482
Diffstat (limited to 'llvm/lib/Target/LoongArch')
-rw-r--r-- | llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/Target/LoongArch/LoongArchInstrInfo.h | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp index 00b806a..eab5cdb6 100644 --- a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp +++ b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp @@ -434,3 +434,28 @@ bool LoongArchInstrInfo::reverseBranchCondition( Cond[0].setImm(getOppositeBranchOpc(Cond[0].getImm())); return false; } + +std::pair<unsigned, unsigned> +LoongArchInstrInfo::decomposeMachineOperandsTargetFlags(unsigned TF) const { + return std::make_pair(TF, 0u); +} + +ArrayRef<std::pair<unsigned, const char *>> +LoongArchInstrInfo::getSerializableDirectMachineOperandTargetFlags() const { + using namespace LoongArchII; + // TODO: Add more target flags. + static const std::pair<unsigned, const char *> TargetFlags[] = { + {MO_CALL, "loongarch-call"}, + {MO_CALL_PLT, "loongarch-call-plt"}, + {MO_PCREL_HI, "loongarch-pcrel-hi"}, + {MO_PCREL_LO, "loongarch-pcrel-lo"}, + {MO_GOT_PC_HI, "loongarch-got-pc-hi"}, + {MO_GOT_PC_LO, "loongarch-got-pc-lo"}, + {MO_LE_HI, "loongarch-le-hi"}, + {MO_LE_LO, "loongarch-le-lo"}, + {MO_IE_PC_HI, "loongarch-ie-pc-hi"}, + {MO_IE_PC_LO, "loongarch-ie-pc-lo"}, + {MO_LD_PC_HI, "loongarch-ld-pc-hi"}, + {MO_GD_PC_HI, "loongarch-gd-pc-hi"}}; + return makeArrayRef(TargetFlags); +} diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.h b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.h index 633d3eb..71bc330 100644 --- a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.h +++ b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.h @@ -74,6 +74,12 @@ public: bool reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; + std::pair<unsigned, unsigned> + decomposeMachineOperandsTargetFlags(unsigned TF) const override; + + ArrayRef<std::pair<unsigned, const char *>> + getSerializableDirectMachineOperandTargetFlags() const override; + protected: const LoongArchSubtarget &STI; }; |