Changeset View
Changeset View
Standalone View
Standalone View
lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Show First 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | MachineInstrBuilder MachineIRBuilder::buildCast(const DstOp &Dst, | ||||
else { | else { | ||||
assert(!SrcTy.isPointer() && !DstTy.isPointer() && "n G_ADDRCAST yet"); | assert(!SrcTy.isPointer() && !DstTy.isPointer() && "n G_ADDRCAST yet"); | ||||
Opcode = TargetOpcode::G_BITCAST; | Opcode = TargetOpcode::G_BITCAST; | ||||
} | } | ||||
return buildInstr(Opcode, Dst, Src); | return buildInstr(Opcode, Dst, Src); | ||||
} | } | ||||
MachineInstrBuilder MachineIRBuilder::buildExtract(unsigned Res, unsigned Src, | MachineInstrBuilder MachineIRBuilder::buildExtract(const DstOp &Dst, | ||||
const SrcOp &Src, | |||||
uint64_t Index) { | uint64_t Index) { | ||||
LLT SrcTy = Src.getLLTTy(*getMRI()); | |||||
LLT DstTy = Dst.getLLTTy(*getMRI()); | |||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
assert(getMRI()->getType(Src).isValid() && "invalid operand type"); | assert(SrcTy.isValid() && "invalid operand type"); | ||||
assert(getMRI()->getType(Res).isValid() && "invalid operand type"); | assert(DstTy.isValid() && "invalid operand type"); | ||||
assert(Index + getMRI()->getType(Res).getSizeInBits() <= | assert(Index + DstTy.getSizeInBits() <= SrcTy.getSizeInBits() && | ||||
getMRI()->getType(Src).getSizeInBits() && | |||||
"extracting off end of register"); | "extracting off end of register"); | ||||
#endif | #endif | ||||
if (getMRI()->getType(Res).getSizeInBits() == | if (DstTy.getSizeInBits() == SrcTy.getSizeInBits()) { | ||||
getMRI()->getType(Src).getSizeInBits()) { | |||||
assert(Index == 0 && "insertion past the end of a register"); | assert(Index == 0 && "insertion past the end of a register"); | ||||
return buildCast(Res, Src); | return buildCast(Dst, Src); | ||||
} | } | ||||
return buildInstr(TargetOpcode::G_EXTRACT) | auto Extract = buildInstr(TargetOpcode::G_EXTRACT); | ||||
.addDef(Res) | Dst.addDefToMIB(*getMRI(), Extract); | ||||
aemerson: Out of curiosity, why does this need changing? | |||||
arsenmAuthorUnsubmitted A random assortment of functions in MachineIRBuilder don't use SrcOp/DstOp, so this makes it consistent with the other operations. I can commit this separately arsenm: A random assortment of functions in MachineIRBuilder don't use SrcOp/DstOp, so this makes it… | |||||
.addUse(Src) | Src.addSrcToMIB(Extract); | ||||
.addImm(Index); | Extract.addImm(Index); | ||||
return Extract; | |||||
} | } | ||||
void MachineIRBuilder::buildSequence(unsigned Res, ArrayRef<unsigned> Ops, | void MachineIRBuilder::buildSequence(unsigned Res, ArrayRef<unsigned> Ops, | ||||
ArrayRef<uint64_t> Indices) { | ArrayRef<uint64_t> Indices) { | ||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
assert(Ops.size() == Indices.size() && "incompatible args"); | assert(Ops.size() == Indices.size() && "incompatible args"); | ||||
assert(!Ops.empty() && "invalid trivial sequence"); | assert(!Ops.empty() && "invalid trivial sequence"); | ||||
assert(std::is_sorted(Indices.begin(), Indices.end()) && | assert(std::is_sorted(Indices.begin(), Indices.end()) && | ||||
▲ Show 20 Lines • Show All 585 Lines • Show Last 20 Lines |
Out of curiosity, why does this need changing?