diff options
author | Tim Northover <tnorthover@apple.com> | 2016-08-19 17:17:06 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2016-08-19 17:17:06 +0000 |
commit | 91c8173093b35392e804a7267c386d147e73979e (patch) | |
tree | 7aecf6871f63e6a6afc21a9e3c23d9e3e896fe27 /llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | |
parent | 170dede75dc30599b1628e83ad45ec940b165af3 (diff) | |
download | bcm5719-llvm-91c8173093b35392e804a7267c386d147e73979e.tar.gz bcm5719-llvm-91c8173093b35392e804a7267c386d147e73979e.zip |
GlobalISel: support overflow arithmetic intrinsics.
Unsigned addition and subtraction can reuse the instructions created to
legalize large width operations (i.e. both produce and consume a carry flag).
Signed operations and multiplies get a dedicated op-with-overflow instruction.
Once this is produced the two values are combined into a struct register (which
will almost always be merged with a corresponding G_EXTRACT as part of
legalization).
llvm-svn: 279278
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index 70a24415f1d..92dbab05e03 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -124,11 +124,11 @@ MachineInstrBuilder MachineIRBuilder::buildStore(LLT VTy, LLT PTy, .addMemOperand(&MMO); } -MachineInstrBuilder MachineIRBuilder::buildAdde(LLT Ty, unsigned Res, - unsigned CarryOut, unsigned Op0, - unsigned Op1, - unsigned CarryIn) { - return buildInstr(TargetOpcode::G_ADDE, Ty) +MachineInstrBuilder MachineIRBuilder::buildUAdde(LLT Ty, unsigned Res, + unsigned CarryOut, + unsigned Op0, unsigned Op1, + unsigned CarryIn) { + return buildInstr(TargetOpcode::G_UADDE, Ty) .addDef(Res) .addDef(CarryOut) .addUse(Op0) @@ -157,12 +157,18 @@ MachineIRBuilder::buildExtract(LLT Ty, ArrayRef<unsigned> Results, unsigned Src, return MIB; } -MachineInstrBuilder MachineIRBuilder::buildSequence(LLT Ty, unsigned Res, - ArrayRef<unsigned> Ops) { +MachineInstrBuilder +MachineIRBuilder::buildSequence(LLT Ty, unsigned Res, + ArrayRef<unsigned> Ops, + ArrayRef<unsigned> Indexes) { + assert(Ops.size() == Indexes.size() && "incompatible args"); + MachineInstrBuilder MIB = buildInstr(TargetOpcode::G_SEQUENCE, Ty); MIB.addDef(Res); - for (auto Op : Ops) - MIB.addUse(Op); + for (unsigned i = 0; i < Ops.size(); ++i) { + MIB.addUse(Ops[i]); + MIB.addImm(Indexes[i]); + } return MIB; } |