Index: lib/Target/Mips/MipsInstrInfo.h =================================================================== --- lib/Target/Mips/MipsInstrInfo.h +++ lib/Target/Mips/MipsInstrInfo.h @@ -152,6 +152,12 @@ bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override; + std::pair + decomposeMachineOperandsTargetFlags(unsigned TF) const override; + + ArrayRef> + getSerializableDirectMachineOperandTargetFlags() const override; + protected: bool isZeroImm(const MachineOperand &op) const; Index: lib/Target/Mips/MipsInstrInfo.cpp =================================================================== --- lib/Target/Mips/MipsInstrInfo.cpp +++ lib/Target/Mips/MipsInstrInfo.cpp @@ -618,3 +618,39 @@ return true; } +std::pair +MipsInstrInfo::decomposeMachineOperandsTargetFlags(unsigned TF) const { + return std::make_pair(TF, 0u); +} + +ArrayRef> +MipsInstrInfo::getSerializableDirectMachineOperandTargetFlags() const { + using namespace MipsII; + + static const std::pair Flags[] = { + {MO_GOT, "mips-got"}, + {MO_GOT_CALL, "mips-got-call"}, + {MO_GPREL, "mips-gprel"}, + {MO_ABS_HI, "mips-abs-hi"}, + {MO_ABS_LO, "mips-abs-lo"}, + {MO_TLSGD, "mips-tlsgd"}, + {MO_TLSLDM, "mips-tlsldm"}, + {MO_DTPREL_HI, "mips-dtprel-hi"}, + {MO_DTPREL_LO, "mips-dtprel-lo"}, + {MO_GOTTPREL, "mips-gottprel"}, + {MO_TPREL_HI, "mips-tprel-hi"}, + {MO_TPREL_LO, "mips-tprel-lo"}, + {MO_GPOFF_HI, "mips-gpoff-hi"}, + {MO_GPOFF_LO, "mips-gpoff-lo"}, + {MO_GOT_DISP, "mips-got-disp"}, + {MO_GOT_PAGE, "mips-got-page"}, + {MO_GOT_OFST, "mips-got-ofst"}, + {MO_HIGHER, "mips-higher"}, + {MO_HIGHEST, "mips-highest"}, + {MO_GOT_HI16, "mips-got-hi16"}, + {MO_GOT_LO16, "mips-got-lo16"}, + {MO_CALL_HI16, "mips-call-hi16"}, + {MO_CALL_LO16, "mips-call-lo16"} + }; + return makeArrayRef(Flags); +} Index: test/CodeGen/Mips/mirparser/target-flags-pic-mxgot-tls.mir =================================================================== --- /dev/null +++ test/CodeGen/Mips/mirparser/target-flags-pic-mxgot-tls.mir @@ -0,0 +1,275 @@ +# RUN: llc -march=mips64 -target-abi n64 -start-before=expand-isel-pseudos \ +# RUN: -stop-after=expand-isel-pseudos -relocation-model=pic -mxgot \ +# RUN: -o /dev/null %s + +# A simple test to show that we can parse the target specific flags: gpoff-hi, +# gpoff-lo, tlsgd, tlsldm, dtprel-hi, dtprel-lo, got-hi, got-lo, call-hi, +# call-lo. + +--- | + @v = global i32 0, align 4 + @k = thread_local global i32 0, align 4 + @j = external thread_local global i32, align 4 + @__tls_guard = internal thread_local global i1 false, align 1 + declare extern_weak void @_ZTH1j() + + declare i32 @_Z1gi(i32 signext) + + define i32 @_Z2k1i(i32 signext %asd) { + entry: + %call = tail call i32 @_Z1gi(i32 signext %asd) + %add = add nsw i32 %call, %asd + %0 = load i32, i32* @v, align 4 + %add1 = add nsw i32 %add, %0 + %.b.i.i = load i1, i1* @__tls_guard, align 1 + br i1 %.b.i.i, label %entry._ZTW1k.exit_crit_edge, label %init.i.i + + entry._ZTW1k.exit_crit_edge: + %.pre = load i32, i32* @k, align 4 + br label %_ZTW1k.exit + + init.i.i: + store i1 true, i1* @__tls_guard, align 1 + %call.i.i.i = tail call i32 @_Z1gi(i32 signext 3) + store i32 %call.i.i.i, i32* @k, align 4 + br label %_ZTW1k.exit + + _ZTW1k.exit: + %1 = phi i32 [ %.pre, %entry._ZTW1k.exit_crit_edge ], [ %call.i.i.i, %init.i.i ] + %add2 = add nsw i32 %add1, %1 + br i1 icmp ne (void ()* @_ZTH1j, void ()* null), label %2, label %_ZTW1j.exit + + ;