summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-07-25 21:01:29 +0000
committerTim Northover <tnorthover@apple.com>2016-07-25 21:01:29 +0000
commit7c9eba90ffdcf35dc587c65b9ff9a5bf3ac0acc7 (patch)
tree1e4ec47f97b7d3a92ab432176a8b0dd911faf72c /llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
parente2e0067352c7e92159f6d29531ac652959349b2d (diff)
downloadbcm5719-llvm-7c9eba90ffdcf35dc587c65b9ff9a5bf3ac0acc7.tar.gz
bcm5719-llvm-7c9eba90ffdcf35dc587c65b9ff9a5bf3ac0acc7.zip
GlobalISel: add generic casts to IRTranslator
This adds LLVM's 3 main cast instructions (inttoptr, ptrtoint, bitcast) to the IRTranslator. The first two are direct translations (with 2 MachineInstr types each). Since LLT discards information, a bitcast might become trivial and we emit a COPY in those cases instead. llvm-svn: 276690
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 2b91584c75d..f18467c4bb4 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -85,6 +85,18 @@ MachineInstr *MachineIRBuilder::buildInstr(unsigned Opcode, LLT Ty,
return NewMI;
}
+MachineInstr *MachineIRBuilder::buildInstr(unsigned Opcode, ArrayRef<LLT> Tys,
+ unsigned Res, unsigned Op0) {
+ MachineInstr *NewMI = buildInstr(Opcode, Tys[0]);
+ for (unsigned i = 1; i < Tys.size(); ++i)
+ NewMI->setType(Tys[i], i);
+
+ MachineInstrBuilder(getMF(), NewMI)
+ .addReg(Res, RegState::Define)
+ .addReg(Op0);
+ return NewMI;
+}
+
MachineInstr *MachineIRBuilder::buildInstr(unsigned Opcode, unsigned Res,
unsigned Op0) {
MachineInstr *NewMI = buildInstr(Opcode, LLT{});
OpenPOWER on IntegriCloud