2010-04-22 20:06:42 +00:00
|
|
|
//===-- FastISel.cpp - Implementation of the FastISel class ---------------===//
|
2008-08-13 20:19:35 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the implementation of the FastISel class.
|
|
|
|
//
|
2008-09-30 20:48:29 +00:00
|
|
|
// "Fast" instruction selection is designed to emit very poor code quickly.
|
|
|
|
// Also, it is not designed to be able to do much lowering, so most illegal
|
2008-10-13 01:59:13 +00:00
|
|
|
// types (e.g. i64 on 32-bit targets) and operations are not supported. It is
|
|
|
|
// also not intended to be able to do much optimization, except in a few cases
|
|
|
|
// where doing optimizations reduces overall compile time. For example, folding
|
|
|
|
// constants into immediate fields is often done, because it's cheap and it
|
|
|
|
// reduces the number of instructions later phases have to examine.
|
2008-09-30 20:48:29 +00:00
|
|
|
//
|
|
|
|
// "Fast" instruction selection is able to fail gracefully and transfer
|
|
|
|
// control to the SelectionDAG selector for operations that it doesn't
|
2008-10-13 01:59:13 +00:00
|
|
|
// support. In many cases, this allows us to avoid duplicating a lot of
|
2008-09-30 20:48:29 +00:00
|
|
|
// the complicated lowering logic that SelectionDAG currently has.
|
|
|
|
//
|
|
|
|
// The intended use for "fast" instruction selection is "-O0" mode
|
|
|
|
// compilation, where the quality of the generated code is irrelevant when
|
2008-10-13 01:59:13 +00:00
|
|
|
// weighed against the speed at which the code can be generated. Also,
|
2008-09-30 20:48:29 +00:00
|
|
|
// at -O0, the LLVM optimizers are not running, and this makes the
|
|
|
|
// compile time of codegen a much higher portion of the overall compile
|
2008-10-13 01:59:13 +00:00
|
|
|
// time. Despite its limitations, "fast" instruction selection is able to
|
2008-09-30 20:48:29 +00:00
|
|
|
// handle enough code on its own to provide noticeable overall speedups
|
|
|
|
// in -O0 compiles.
|
|
|
|
//
|
|
|
|
// Basic operations are supported in a target-independent way, by reading
|
|
|
|
// the same instruction descriptions that the SelectionDAG selector reads,
|
|
|
|
// and identifying simple arithmetic operations that can be directly selected
|
2008-10-13 01:59:13 +00:00
|
|
|
// from simple operators. More complicated operations currently require
|
2008-09-30 20:48:29 +00:00
|
|
|
// target-specific code.
|
|
|
|
//
|
2008-08-13 20:19:35 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-09-25 17:05:24 +00:00
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/GlobalVariable.h"
|
2008-08-19 22:31:46 +00:00
|
|
|
#include "llvm/Instructions.h"
|
2008-09-25 17:05:24 +00:00
|
|
|
#include "llvm/IntrinsicInst.h"
|
2008-08-13 20:19:35 +00:00
|
|
|
#include "llvm/CodeGen/FastISel.h"
|
2010-07-07 16:01:37 +00:00
|
|
|
#include "llvm/CodeGen/FunctionLoweringInfo.h"
|
2008-08-13 20:19:35 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2008-09-25 17:05:24 +00:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
2008-08-13 20:19:35 +00:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2009-01-13 00:35:13 +00:00
|
|
|
#include "llvm/Analysis/DebugInfo.h"
|
2010-07-01 03:49:38 +00:00
|
|
|
#include "llvm/Analysis/Loads.h"
|
2008-08-20 22:45:34 +00:00
|
|
|
#include "llvm/Target/TargetData.h"
|
2008-08-13 20:19:35 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2008-08-20 22:45:34 +00:00
|
|
|
#include "llvm/Target/TargetLowering.h"
|
2008-08-20 21:05:57 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2010-04-20 15:00:41 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-12-06 22:39:26 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2008-08-13 20:19:35 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
/// startNewBlock - Set the current block to which generated machine
|
|
|
|
/// instructions will be appended, and clear the local CSE map.
|
|
|
|
///
|
|
|
|
void FastISel::startNewBlock() {
|
|
|
|
LocalValueMap.clear();
|
|
|
|
|
|
|
|
// Start out as null, meaining no local-value instructions have
|
|
|
|
// been emitted.
|
|
|
|
LastLocalValue = 0;
|
|
|
|
|
|
|
|
// Advance the last local value past any EH_LABEL instructions.
|
|
|
|
MachineBasicBlock::iterator
|
|
|
|
I = FuncInfo.MBB->begin(), E = FuncInfo.MBB->end();
|
|
|
|
while (I != E && I->getOpcode() == TargetOpcode::EH_LABEL) {
|
|
|
|
LastLocalValue = I;
|
|
|
|
++I;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool FastISel::hasTrivialKill(const Value *V) const {
|
2010-05-14 22:53:18 +00:00
|
|
|
// Don't consider constants or arguments to have trivial kills.
|
2010-05-11 23:54:07 +00:00
|
|
|
const Instruction *I = dyn_cast<Instruction>(V);
|
2010-05-14 22:53:18 +00:00
|
|
|
if (!I)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// No-op casts are trivially coalesced by fast-isel.
|
|
|
|
if (const CastInst *Cast = dyn_cast<CastInst>(I))
|
|
|
|
if (Cast->isNoopCast(TD.getIntPtrType(Cast->getContext())) &&
|
|
|
|
!hasTrivialKill(Cast->getOperand(0)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Only instructions with a single use in the same basic block are considered
|
|
|
|
// to have trivial kills.
|
|
|
|
return I->hasOneUse() &&
|
|
|
|
!(I->getOpcode() == Instruction::BitCast ||
|
|
|
|
I->getOpcode() == Instruction::PtrToInt ||
|
|
|
|
I->getOpcode() == Instruction::IntToPtr) &&
|
2010-07-22 13:36:47 +00:00
|
|
|
cast<Instruction>(*I->use_begin())->getParent() == I->getParent();
|
2010-05-11 23:54:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
unsigned FastISel::getRegForValue(const Value *V) {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT RealVT = TLI.getValueType(V->getType(), /*AllowUnknown=*/true);
|
2009-04-07 20:40:11 +00:00
|
|
|
// Don't handle non-simple values in FastISel.
|
|
|
|
if (!RealVT.isSimple())
|
|
|
|
return 0;
|
2008-09-10 21:01:08 +00:00
|
|
|
|
2008-12-08 07:57:47 +00:00
|
|
|
// Ignore illegal types. We must do this before looking up the value
|
|
|
|
// in ValueMap because Arguments are given virtual registers regardless
|
|
|
|
// of whether FastISel can handle them.
|
2009-08-11 20:47:22 +00:00
|
|
|
MVT VT = RealVT.getSimpleVT();
|
2008-09-10 21:01:08 +00:00
|
|
|
if (!TLI.isTypeLegal(VT)) {
|
2009-08-11 20:47:22 +00:00
|
|
|
// Promote MVT::i1 to a legal type though, because it's common and easy.
|
|
|
|
if (VT == MVT::i1)
|
2009-08-12 00:36:31 +00:00
|
|
|
VT = TLI.getTypeToTransformTo(V->getContext(), VT).getSimpleVT();
|
2008-09-10 21:01:08 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-08 07:57:47 +00:00
|
|
|
// Look up the value to see if we already have a register for it. We
|
|
|
|
// cache values defined by Instructions across blocks, and other values
|
|
|
|
// only locally. This is because Instructions already have the SSA
|
2010-01-12 04:30:26 +00:00
|
|
|
// def-dominates-use requirement enforced.
|
2010-07-07 16:29:44 +00:00
|
|
|
DenseMap<const Value *, unsigned>::iterator I = FuncInfo.ValueMap.find(V);
|
2010-07-10 09:00:22 +00:00
|
|
|
if (I != FuncInfo.ValueMap.end()) {
|
|
|
|
unsigned Reg = I->second;
|
|
|
|
return Reg;
|
|
|
|
}
|
2008-12-08 07:57:47 +00:00
|
|
|
unsigned Reg = LocalValueMap[V];
|
|
|
|
if (Reg != 0)
|
|
|
|
return Reg;
|
|
|
|
|
2010-05-06 00:02:14 +00:00
|
|
|
// In bottom-up mode, just create the virtual register which will be used
|
|
|
|
// to hold the value. It will be materialized later.
|
2010-07-10 09:00:22 +00:00
|
|
|
if (isa<Instruction>(V) &&
|
|
|
|
(!isa<AllocaInst>(V) ||
|
|
|
|
!FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(V))))
|
|
|
|
return FuncInfo.InitializeRegForValue(V);
|
|
|
|
|
2010-07-14 01:07:44 +00:00
|
|
|
SavePoint SaveInsertPt = enterLocalValueArea();
|
2010-07-10 09:00:22 +00:00
|
|
|
|
|
|
|
// Materialize the value in a register. Emit any instructions in the
|
|
|
|
// local value area.
|
|
|
|
Reg = materializeRegForValue(V, VT);
|
|
|
|
|
|
|
|
leaveLocalValueArea(SaveInsertPt);
|
2010-05-06 00:02:14 +00:00
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
return Reg;
|
2010-05-03 23:36:34 +00:00
|
|
|
}
|
|
|
|
|
2010-08-17 01:30:33 +00:00
|
|
|
/// materializeRegForValue - Helper for getRegForValue. This function is
|
2010-05-03 23:36:34 +00:00
|
|
|
/// called when the value isn't already available in a register and must
|
|
|
|
/// be materialized with new instructions.
|
|
|
|
unsigned FastISel::materializeRegForValue(const Value *V, MVT VT) {
|
|
|
|
unsigned Reg = 0;
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
2008-09-19 22:16:54 +00:00
|
|
|
if (CI->getValue().getActiveBits() <= 64)
|
|
|
|
Reg = FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue());
|
2008-09-10 20:11:02 +00:00
|
|
|
} else if (isa<AllocaInst>(V)) {
|
2008-09-19 22:16:54 +00:00
|
|
|
Reg = TargetMaterializeAlloca(cast<AllocaInst>(V));
|
2008-08-28 21:19:07 +00:00
|
|
|
} else if (isa<ConstantPointerNull>(V)) {
|
2008-10-07 22:03:27 +00:00
|
|
|
// Translate this as an integer zero so that it can be
|
|
|
|
// local-CSE'd with actual integer zeros.
|
2009-08-13 21:58:54 +00:00
|
|
|
Reg =
|
|
|
|
getRegForValue(Constant::getNullValue(TD.getIntPtrType(V->getContext())));
|
2010-04-15 01:51:59 +00:00
|
|
|
} else if (const ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
|
2010-04-13 17:07:06 +00:00
|
|
|
// Try to emit the constant directly.
|
2008-09-03 23:32:19 +00:00
|
|
|
Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF);
|
2008-08-27 18:10:19 +00:00
|
|
|
|
|
|
|
if (!Reg) {
|
2010-04-13 17:07:06 +00:00
|
|
|
// Try to emit the constant by using an integer constant with a cast.
|
2008-08-27 18:10:19 +00:00
|
|
|
const APFloat &Flt = CF->getValueAPF();
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT IntVT = TLI.getPointerTy();
|
2008-08-27 18:10:19 +00:00
|
|
|
|
|
|
|
uint64_t x[2];
|
|
|
|
uint32_t IntBitWidth = IntVT.getSizeInBits();
|
2008-10-09 23:00:39 +00:00
|
|
|
bool isExact;
|
|
|
|
(void) Flt.convertToInteger(x, IntBitWidth, /*isSigned=*/true,
|
|
|
|
APFloat::rmTowardZero, &isExact);
|
|
|
|
if (isExact) {
|
2008-09-19 22:16:54 +00:00
|
|
|
APInt IntVal(IntBitWidth, 2, x);
|
2008-08-27 18:10:19 +00:00
|
|
|
|
2009-07-22 00:24:57 +00:00
|
|
|
unsigned IntegerReg =
|
2009-07-24 23:12:02 +00:00
|
|
|
getRegForValue(ConstantInt::get(V->getContext(), IntVal));
|
2008-09-19 22:16:54 +00:00
|
|
|
if (IntegerReg != 0)
|
2010-05-11 23:54:07 +00:00
|
|
|
Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP,
|
|
|
|
IntegerReg, /*Kill=*/false);
|
2008-09-19 22:16:54 +00:00
|
|
|
}
|
2008-08-27 18:10:19 +00:00
|
|
|
}
|
2010-04-15 01:51:59 +00:00
|
|
|
} else if (const Operator *Op = dyn_cast<Operator>(V)) {
|
2010-07-01 02:58:57 +00:00
|
|
|
if (!SelectOperator(Op, Op->getOpcode()))
|
|
|
|
if (!isa<Instruction>(Op) ||
|
|
|
|
!TargetSelectInstruction(cast<Instruction>(Op)))
|
|
|
|
return 0;
|
2010-06-21 14:17:46 +00:00
|
|
|
Reg = lookUpRegForValue(Op);
|
2008-08-28 21:19:07 +00:00
|
|
|
} else if (isa<UndefValue>(V)) {
|
2008-09-03 23:32:19 +00:00
|
|
|
Reg = createResultReg(TLI.getRegClassFor(VT));
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
|
|
|
|
TII.get(TargetOpcode::IMPLICIT_DEF), Reg);
|
2008-08-27 18:10:19 +00:00
|
|
|
}
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-25 01:28:51 +00:00
|
|
|
// If target-independent code couldn't handle the value, give target-specific
|
|
|
|
// code a try.
|
2008-09-05 23:36:01 +00:00
|
|
|
if (!Reg && isa<Constant>(V))
|
2008-09-19 22:16:54 +00:00
|
|
|
Reg = TargetMaterializeConstant(cast<Constant>(V));
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-19 22:16:54 +00:00
|
|
|
// Don't cache constant materializations in the general ValueMap.
|
|
|
|
// To do so would require tracking what uses they dominate.
|
2010-07-10 09:00:22 +00:00
|
|
|
if (Reg != 0) {
|
2008-09-25 01:28:51 +00:00
|
|
|
LocalValueMap[V] = Reg;
|
2010-07-10 09:00:22 +00:00
|
|
|
LastLocalValue = MRI.getVRegDef(Reg);
|
|
|
|
}
|
2008-09-03 23:32:19 +00:00
|
|
|
return Reg;
|
2008-08-27 18:10:19 +00:00
|
|
|
}
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
unsigned FastISel::lookUpRegForValue(const Value *V) {
|
2008-09-09 01:26:59 +00:00
|
|
|
// Look up the value to see if we already have a register for it. We
|
|
|
|
// cache values defined by Instructions across blocks, and other values
|
|
|
|
// only locally. This is because Instructions already have the SSA
|
2010-05-03 23:36:34 +00:00
|
|
|
// def-dominates-use requirement enforced.
|
2010-07-07 16:29:44 +00:00
|
|
|
DenseMap<const Value *, unsigned>::iterator I = FuncInfo.ValueMap.find(V);
|
|
|
|
if (I != FuncInfo.ValueMap.end())
|
2010-06-21 14:21:47 +00:00
|
|
|
return I->second;
|
2008-09-09 01:26:59 +00:00
|
|
|
return LocalValueMap[V];
|
|
|
|
}
|
|
|
|
|
2008-08-30 00:38:46 +00:00
|
|
|
/// UpdateValueMap - Update the value map to include the new mapping for this
|
|
|
|
/// instruction, or insert an extra copy to get the result in a previous
|
|
|
|
/// determined register.
|
|
|
|
/// NOTE: This is only necessary because we might select a block that uses
|
|
|
|
/// a value before we select the block that defines the value. It might be
|
|
|
|
/// possible to fix this by selecting blocks in reverse postorder.
|
2010-04-15 01:51:59 +00:00
|
|
|
unsigned FastISel::UpdateValueMap(const Value *I, unsigned Reg) {
|
2008-09-05 18:18:20 +00:00
|
|
|
if (!isa<Instruction>(I)) {
|
|
|
|
LocalValueMap[I] = Reg;
|
2009-04-12 07:45:01 +00:00
|
|
|
return Reg;
|
|
|
|
}
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2010-07-07 16:29:44 +00:00
|
|
|
unsigned &AssignedReg = FuncInfo.ValueMap[I];
|
2009-04-12 07:45:01 +00:00
|
|
|
if (AssignedReg == 0)
|
2010-07-10 09:00:22 +00:00
|
|
|
// Use the new register.
|
2009-04-12 07:45:01 +00:00
|
|
|
AssignedReg = Reg;
|
2009-04-12 07:46:30 +00:00
|
|
|
else if (Reg != AssignedReg) {
|
2010-07-10 09:00:22 +00:00
|
|
|
// Arrange for uses of AssignedReg to be replaced by uses of Reg.
|
|
|
|
FuncInfo.RegFixups[AssignedReg] = Reg;
|
|
|
|
|
|
|
|
AssignedReg = Reg;
|
2008-09-05 18:18:20 +00:00
|
|
|
}
|
2010-07-10 09:00:22 +00:00
|
|
|
|
2009-04-12 07:45:01 +00:00
|
|
|
return AssignedReg;
|
2008-08-30 00:38:46 +00:00
|
|
|
}
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
std::pair<unsigned, bool> FastISel::getRegForGEPIndex(const Value *Idx) {
|
2008-12-08 07:57:47 +00:00
|
|
|
unsigned IdxN = getRegForValue(Idx);
|
|
|
|
if (IdxN == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
2010-05-11 23:54:07 +00:00
|
|
|
return std::pair<unsigned, bool>(0, false);
|
|
|
|
|
|
|
|
bool IdxNIsKill = hasTrivialKill(Idx);
|
2008-12-08 07:57:47 +00:00
|
|
|
|
|
|
|
// If the index is smaller or larger than intptr_t, truncate or extend it.
|
2009-08-11 21:59:30 +00:00
|
|
|
MVT PtrVT = TLI.getPointerTy();
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT IdxVT = EVT::getEVT(Idx->getType(), /*HandleUnknown=*/false);
|
2010-05-11 23:54:07 +00:00
|
|
|
if (IdxVT.bitsLT(PtrVT)) {
|
|
|
|
IdxN = FastEmit_r(IdxVT.getSimpleVT(), PtrVT, ISD::SIGN_EXTEND,
|
|
|
|
IdxN, IdxNIsKill);
|
|
|
|
IdxNIsKill = true;
|
|
|
|
}
|
|
|
|
else if (IdxVT.bitsGT(PtrVT)) {
|
|
|
|
IdxN = FastEmit_r(IdxVT.getSimpleVT(), PtrVT, ISD::TRUNCATE,
|
|
|
|
IdxN, IdxNIsKill);
|
|
|
|
IdxNIsKill = true;
|
|
|
|
}
|
|
|
|
return std::pair<unsigned, bool>(IdxN, IdxNIsKill);
|
2008-12-08 07:57:47 +00:00
|
|
|
}
|
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
void FastISel::recomputeInsertPt() {
|
|
|
|
if (getLastLocalValue()) {
|
|
|
|
FuncInfo.InsertPt = getLastLocalValue();
|
2010-07-19 22:48:56 +00:00
|
|
|
FuncInfo.MBB = FuncInfo.InsertPt->getParent();
|
2010-07-10 09:00:22 +00:00
|
|
|
++FuncInfo.InsertPt;
|
|
|
|
} else
|
|
|
|
FuncInfo.InsertPt = FuncInfo.MBB->getFirstNonPHI();
|
|
|
|
|
|
|
|
// Now skip past any EH_LABELs, which must remain at the beginning.
|
|
|
|
while (FuncInfo.InsertPt != FuncInfo.MBB->end() &&
|
|
|
|
FuncInfo.InsertPt->getOpcode() == TargetOpcode::EH_LABEL)
|
|
|
|
++FuncInfo.InsertPt;
|
|
|
|
}
|
|
|
|
|
2010-07-14 01:07:44 +00:00
|
|
|
FastISel::SavePoint FastISel::enterLocalValueArea() {
|
2010-07-10 09:00:22 +00:00
|
|
|
MachineBasicBlock::iterator OldInsertPt = FuncInfo.InsertPt;
|
2010-07-14 22:01:31 +00:00
|
|
|
DebugLoc OldDL = DL;
|
2010-07-10 09:00:22 +00:00
|
|
|
recomputeInsertPt();
|
2010-07-14 01:07:44 +00:00
|
|
|
DL = DebugLoc();
|
2010-07-14 22:01:31 +00:00
|
|
|
SavePoint SP = { OldInsertPt, OldDL };
|
2010-07-14 01:07:44 +00:00
|
|
|
return SP;
|
2010-07-10 09:00:22 +00:00
|
|
|
}
|
|
|
|
|
2010-07-14 01:07:44 +00:00
|
|
|
void FastISel::leaveLocalValueArea(SavePoint OldInsertPt) {
|
2010-07-10 09:00:22 +00:00
|
|
|
if (FuncInfo.InsertPt != FuncInfo.MBB->begin())
|
|
|
|
LastLocalValue = llvm::prior(FuncInfo.InsertPt);
|
|
|
|
|
|
|
|
// Restore the previous insert position.
|
2010-07-14 01:07:44 +00:00
|
|
|
FuncInfo.InsertPt = OldInsertPt.InsertPt;
|
|
|
|
DL = OldInsertPt.DL;
|
2010-07-10 09:00:22 +00:00
|
|
|
}
|
|
|
|
|
2008-08-20 00:11:48 +00:00
|
|
|
/// SelectBinaryOp - Select and emit code for a binary operator instruction,
|
|
|
|
/// which has an opcode which directly corresponds to the given ISD opcode.
|
|
|
|
///
|
2010-04-15 01:51:59 +00:00
|
|
|
bool FastISel::SelectBinaryOp(const User *I, unsigned ISDOpcode) {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = EVT::getEVT(I->getType(), /*HandleUnknown=*/true);
|
2009-08-11 20:47:22 +00:00
|
|
|
if (VT == MVT::Other || !VT.isSimple())
|
2008-08-21 01:41:07 +00:00
|
|
|
// Unhandled type. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2008-09-05 18:44:22 +00:00
|
|
|
|
2008-08-26 20:52:40 +00:00
|
|
|
// We only handle legal types. For example, on x86-32 the instruction
|
|
|
|
// selector contains all of the 64-bit instructions from x86-64,
|
|
|
|
// under the assumption that i64 won't be used if the target doesn't
|
|
|
|
// support it.
|
2008-09-05 18:44:22 +00:00
|
|
|
if (!TLI.isTypeLegal(VT)) {
|
2009-08-11 20:47:22 +00:00
|
|
|
// MVT::i1 is special. Allow AND, OR, or XOR because they
|
2008-09-05 18:44:22 +00:00
|
|
|
// don't require additional zeroing, which makes them easy.
|
2009-08-11 20:47:22 +00:00
|
|
|
if (VT == MVT::i1 &&
|
2008-09-25 17:22:52 +00:00
|
|
|
(ISDOpcode == ISD::AND || ISDOpcode == ISD::OR ||
|
|
|
|
ISDOpcode == ISD::XOR))
|
2009-08-12 00:36:31 +00:00
|
|
|
VT = TLI.getTypeToTransformTo(I->getContext(), VT);
|
2008-09-05 18:44:22 +00:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2008-08-21 01:41:07 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
unsigned Op0 = getRegForValue(I->getOperand(0));
|
2008-08-21 01:41:07 +00:00
|
|
|
if (Op0 == 0)
|
2008-08-20 00:35:17 +00:00
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool Op0IsKill = hasTrivialKill(I->getOperand(0));
|
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
// Check if the second operand is a constant and handle it appropriately.
|
|
|
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
|
2008-08-27 18:10:19 +00:00
|
|
|
unsigned ResultReg = FastEmit_ri(VT.getSimpleVT(), VT.getSimpleVT(),
|
2010-05-11 23:54:07 +00:00
|
|
|
ISDOpcode, Op0, Op0IsKill,
|
|
|
|
CI->getZExtValue());
|
2008-08-27 18:10:19 +00:00
|
|
|
if (ResultReg != 0) {
|
|
|
|
// We successfully emitted code for the given LLVM Instruction.
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, ResultReg);
|
2008-08-27 18:10:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-08-21 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 01:09:54 +00:00
|
|
|
// Check if the second operand is a constant float.
|
|
|
|
if (ConstantFP *CF = dyn_cast<ConstantFP>(I->getOperand(1))) {
|
2008-08-27 18:10:19 +00:00
|
|
|
unsigned ResultReg = FastEmit_rf(VT.getSimpleVT(), VT.getSimpleVT(),
|
2010-05-11 23:54:07 +00:00
|
|
|
ISDOpcode, Op0, Op0IsKill, CF);
|
2008-08-27 18:10:19 +00:00
|
|
|
if (ResultReg != 0) {
|
|
|
|
// We successfully emitted code for the given LLVM Instruction.
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, ResultReg);
|
2008-08-27 18:10:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-08-27 01:09:54 +00:00
|
|
|
}
|
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
unsigned Op1 = getRegForValue(I->getOperand(1));
|
2008-08-21 01:41:07 +00:00
|
|
|
if (Op1 == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
2008-08-20 00:11:48 +00:00
|
|
|
return false;
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool Op1IsKill = hasTrivialKill(I->getOperand(1));
|
|
|
|
|
2008-08-27 18:10:19 +00:00
|
|
|
// Now we have both operands in registers. Emit the instruction.
|
2008-08-25 23:58:18 +00:00
|
|
|
unsigned ResultReg = FastEmit_rr(VT.getSimpleVT(), VT.getSimpleVT(),
|
2010-05-11 23:54:07 +00:00
|
|
|
ISDOpcode,
|
|
|
|
Op0, Op0IsKill,
|
|
|
|
Op1, Op1IsKill);
|
2008-08-20 00:11:48 +00:00
|
|
|
if (ResultReg == 0)
|
|
|
|
// Target-specific code wasn't able to find a machine opcode for
|
|
|
|
// the given ISD opcode and type. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
|
2008-08-20 00:23:20 +00:00
|
|
|
// We successfully emitted code for the given LLVM Instruction.
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, ResultReg);
|
2008-08-20 00:11:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool FastISel::SelectGetElementPtr(const User *I) {
|
2008-09-03 23:12:08 +00:00
|
|
|
unsigned N = getRegForValue(I->getOperand(0));
|
2008-08-20 22:45:34 +00:00
|
|
|
if (N == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool NIsKill = hasTrivialKill(I->getOperand(0));
|
|
|
|
|
2008-08-20 22:45:34 +00:00
|
|
|
const Type *Ty = I->getOperand(0)->getType();
|
2009-08-11 20:47:22 +00:00
|
|
|
MVT VT = TLI.getPointerTy();
|
2010-04-15 01:51:59 +00:00
|
|
|
for (GetElementPtrInst::const_op_iterator OI = I->op_begin()+1,
|
|
|
|
E = I->op_end(); OI != E; ++OI) {
|
|
|
|
const Value *Idx = *OI;
|
2008-08-20 22:45:34 +00:00
|
|
|
if (const StructType *StTy = dyn_cast<StructType>(Ty)) {
|
|
|
|
unsigned Field = cast<ConstantInt>(Idx)->getZExtValue();
|
|
|
|
if (Field) {
|
|
|
|
// N = N + Offset
|
|
|
|
uint64_t Offs = TD.getStructLayout(StTy)->getElementOffset(Field);
|
|
|
|
// FIXME: This can be optimized by combining the add with a
|
|
|
|
// subsequent one.
|
2010-05-11 23:54:07 +00:00
|
|
|
N = FastEmit_ri_(VT, ISD::ADD, N, NIsKill, Offs, VT);
|
2008-08-20 22:45:34 +00:00
|
|
|
if (N == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2010-05-11 23:54:07 +00:00
|
|
|
NIsKill = true;
|
2008-08-20 22:45:34 +00:00
|
|
|
}
|
|
|
|
Ty = StTy->getElementType(Field);
|
|
|
|
} else {
|
|
|
|
Ty = cast<SequentialType>(Ty)->getElementType();
|
|
|
|
|
|
|
|
// If this is a constant subscript, handle it quickly.
|
2010-04-15 01:51:59 +00:00
|
|
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(Idx)) {
|
2010-06-18 14:22:04 +00:00
|
|
|
if (CI->isZero()) continue;
|
2010-11-23 03:31:01 +00:00
|
|
|
uint64_t Offs =
|
2009-05-09 07:06:46 +00:00
|
|
|
TD.getTypeAllocSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
|
2010-05-11 23:54:07 +00:00
|
|
|
N = FastEmit_ri_(VT, ISD::ADD, N, NIsKill, Offs, VT);
|
2008-08-20 22:45:34 +00:00
|
|
|
if (N == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2010-05-11 23:54:07 +00:00
|
|
|
NIsKill = true;
|
2008-08-20 22:45:34 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-08-20 22:45:34 +00:00
|
|
|
// N = N + Idx * ElementSize;
|
2009-05-09 07:06:46 +00:00
|
|
|
uint64_t ElementSize = TD.getTypeAllocSize(Ty);
|
2010-05-11 23:54:07 +00:00
|
|
|
std::pair<unsigned, bool> Pair = getRegForGEPIndex(Idx);
|
|
|
|
unsigned IdxN = Pair.first;
|
|
|
|
bool IdxNIsKill = Pair.second;
|
2008-08-20 22:45:34 +00:00
|
|
|
if (IdxN == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
|
2008-08-26 20:57:08 +00:00
|
|
|
if (ElementSize != 1) {
|
2010-05-11 23:54:07 +00:00
|
|
|
IdxN = FastEmit_ri_(VT, ISD::MUL, IdxN, IdxNIsKill, ElementSize, VT);
|
2008-08-26 20:57:08 +00:00
|
|
|
if (IdxN == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2010-05-11 23:54:07 +00:00
|
|
|
IdxNIsKill = true;
|
2008-08-26 20:57:08 +00:00
|
|
|
}
|
2010-05-11 23:54:07 +00:00
|
|
|
N = FastEmit_rr(VT, VT, ISD::ADD, N, NIsKill, IdxN, IdxNIsKill);
|
2008-08-20 22:45:34 +00:00
|
|
|
if (N == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We successfully emitted code for the given LLVM Instruction.
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, N);
|
2008-08-20 22:45:34 +00:00
|
|
|
return true;
|
2008-08-20 00:11:48 +00:00
|
|
|
}
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool FastISel::SelectCall(const User *I) {
|
|
|
|
const Function *F = cast<CallInst>(I)->getCalledFunction();
|
2008-09-25 17:05:24 +00:00
|
|
|
if (!F) return false;
|
|
|
|
|
2010-04-13 17:07:06 +00:00
|
|
|
// Handle selected intrinsic function calls.
|
2008-09-25 17:05:24 +00:00
|
|
|
unsigned IID = F->getIntrinsicID();
|
|
|
|
switch (IID) {
|
|
|
|
default: break;
|
2009-02-13 02:16:35 +00:00
|
|
|
case Intrinsic::dbg_declare: {
|
2010-04-15 01:51:59 +00:00
|
|
|
const DbgDeclareInst *DI = cast<DbgDeclareInst>(I);
|
2010-05-07 22:04:20 +00:00
|
|
|
if (!DIVariable(DI->getVariable()).Verify() ||
|
2010-07-07 16:29:44 +00:00
|
|
|
!FuncInfo.MF->getMMI().hasDebugInfo())
|
2009-07-02 22:43:26 +00:00
|
|
|
return true;
|
2009-02-13 02:16:35 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
const Value *Address = DI->getAddress();
|
2010-09-14 20:29:31 +00:00
|
|
|
if (!Address || isa<UndefValue>(Address) || isa<AllocaInst>(Address))
|
2010-02-06 02:26:02 +00:00
|
|
|
return true;
|
2010-09-14 20:29:31 +00:00
|
|
|
|
|
|
|
unsigned Reg = 0;
|
|
|
|
unsigned Offset = 0;
|
|
|
|
if (const Argument *Arg = dyn_cast<Argument>(Address)) {
|
|
|
|
if (Arg->hasByValAttr()) {
|
|
|
|
// Byval arguments' frame index is recorded during argument lowering.
|
|
|
|
// Use this info directly.
|
|
|
|
Offset = FuncInfo.getByValArgumentFrameIndex(Arg);
|
|
|
|
if (Offset)
|
|
|
|
Reg = TRI.getFrameRegister(*FuncInfo.MF);
|
2010-11-23 03:31:01 +00:00
|
|
|
}
|
2010-09-10 20:32:09 +00:00
|
|
|
}
|
2010-09-14 20:29:31 +00:00
|
|
|
if (!Reg)
|
|
|
|
Reg = getRegForValue(Address);
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2010-09-14 20:29:31 +00:00
|
|
|
if (Reg)
|
2010-11-23 03:31:01 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
|
2010-09-14 20:29:31 +00:00
|
|
|
TII.get(TargetOpcode::DBG_VALUE))
|
|
|
|
.addReg(Reg, RegState::Debug).addImm(Offset)
|
|
|
|
.addMetadata(DI->getVariable());
|
2008-09-25 17:05:24 +00:00
|
|
|
return true;
|
2009-02-13 02:16:35 +00:00
|
|
|
}
|
2010-02-26 20:01:55 +00:00
|
|
|
case Intrinsic::dbg_value: {
|
2010-04-07 01:15:14 +00:00
|
|
|
// This form of DBG_VALUE is target-independent.
|
2010-04-15 01:51:59 +00:00
|
|
|
const DbgValueInst *DI = cast<DbgValueInst>(I);
|
2010-02-26 20:01:55 +00:00
|
|
|
const TargetInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);
|
2010-04-15 01:51:59 +00:00
|
|
|
const Value *V = DI->getValue();
|
2010-02-26 20:01:55 +00:00
|
|
|
if (!V) {
|
|
|
|
// Currently the optimizer can produce this; insert an undef to
|
|
|
|
// help debugging. Probably the optimizer should not do this.
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
|
|
|
.addReg(0U).addImm(DI->getOffset())
|
|
|
|
.addMetadata(DI->getVariable());
|
2010-04-15 01:51:59 +00:00
|
|
|
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
|
|
|
.addImm(CI->getZExtValue()).addImm(DI->getOffset())
|
|
|
|
.addMetadata(DI->getVariable());
|
2010-04-15 01:51:59 +00:00
|
|
|
} else if (const ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
|
|
|
.addFPImm(CF).addImm(DI->getOffset())
|
|
|
|
.addMetadata(DI->getVariable());
|
2010-02-26 20:01:55 +00:00
|
|
|
} else if (unsigned Reg = lookUpRegForValue(V)) {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
|
|
|
.addReg(Reg, RegState::Debug).addImm(DI->getOffset())
|
|
|
|
.addMetadata(DI->getVariable());
|
2010-02-26 20:01:55 +00:00
|
|
|
} else {
|
|
|
|
// We can't yet handle anything else here because it would require
|
|
|
|
// generating code, thus altering codegen because of debug info.
|
2010-12-06 22:39:26 +00:00
|
|
|
DEBUG(dbgs() << "Dropping debug info for " << DI);
|
2010-11-23 03:31:01 +00:00
|
|
|
}
|
2010-02-26 20:01:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-10-14 23:54:11 +00:00
|
|
|
case Intrinsic::eh_exception: {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = TLI.getValueType(I->getType());
|
2008-10-14 23:54:11 +00:00
|
|
|
switch (TLI.getOperationAction(ISD::EXCEPTIONADDR, VT)) {
|
|
|
|
default: break;
|
|
|
|
case TargetLowering::Expand: {
|
2010-07-10 09:00:22 +00:00
|
|
|
assert(FuncInfo.MBB->isLandingPad() &&
|
|
|
|
"Call to eh.exception not in landing pad!");
|
2008-10-14 23:54:11 +00:00
|
|
|
unsigned Reg = TLI.getExceptionAddressRegister();
|
|
|
|
const TargetRegisterClass *RC = TLI.getRegClassFor(VT);
|
|
|
|
unsigned ResultReg = createResultReg(RC);
|
2010-07-11 03:31:00 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(Reg);
|
2008-10-14 23:54:11 +00:00
|
|
|
UpdateValueMap(I, ResultReg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 16:11:37 +00:00
|
|
|
case Intrinsic::eh_selector: {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = TLI.getValueType(I->getType());
|
2008-10-14 23:54:11 +00:00
|
|
|
switch (TLI.getOperationAction(ISD::EHSELECTION, VT)) {
|
|
|
|
default: break;
|
|
|
|
case TargetLowering::Expand: {
|
2010-07-10 09:00:22 +00:00
|
|
|
if (FuncInfo.MBB->isLandingPad())
|
|
|
|
AddCatchInfo(*cast<CallInst>(I), &FuncInfo.MF->getMMI(), FuncInfo.MBB);
|
2010-04-05 06:05:26 +00:00
|
|
|
else {
|
2008-10-14 23:54:11 +00:00
|
|
|
#ifndef NDEBUG
|
2010-07-07 16:29:44 +00:00
|
|
|
FuncInfo.CatchInfoLost.insert(cast<CallInst>(I));
|
2008-10-14 23:54:11 +00:00
|
|
|
#endif
|
2010-04-05 06:05:26 +00:00
|
|
|
// FIXME: Mark exception selector register as live in. Hack for PR1508.
|
2008-10-14 23:54:11 +00:00
|
|
|
unsigned Reg = TLI.getExceptionSelectorRegister();
|
2010-07-10 09:00:22 +00:00
|
|
|
if (Reg) FuncInfo.MBB->addLiveIn(Reg);
|
2008-10-14 23:54:11 +00:00
|
|
|
}
|
2010-04-05 06:05:26 +00:00
|
|
|
|
|
|
|
unsigned Reg = TLI.getExceptionSelectorRegister();
|
|
|
|
EVT SrcVT = TLI.getPointerTy();
|
|
|
|
const TargetRegisterClass *RC = TLI.getRegClassFor(SrcVT);
|
|
|
|
unsigned ResultReg = createResultReg(RC);
|
2010-07-11 03:31:00 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(Reg);
|
2010-04-05 06:05:26 +00:00
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool ResultRegIsKill = hasTrivialKill(I);
|
|
|
|
|
2010-04-05 06:05:26 +00:00
|
|
|
// Cast the register to the type of the selector.
|
|
|
|
if (SrcVT.bitsGT(MVT::i32))
|
|
|
|
ResultReg = FastEmit_r(SrcVT.getSimpleVT(), MVT::i32, ISD::TRUNCATE,
|
2010-05-11 23:54:07 +00:00
|
|
|
ResultReg, ResultRegIsKill);
|
2010-04-05 06:05:26 +00:00
|
|
|
else if (SrcVT.bitsLT(MVT::i32))
|
|
|
|
ResultReg = FastEmit_r(SrcVT.getSimpleVT(), MVT::i32,
|
2010-05-11 23:54:07 +00:00
|
|
|
ISD::SIGN_EXTEND, ResultReg, ResultRegIsKill);
|
2010-04-05 06:05:26 +00:00
|
|
|
if (ResultReg == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
UpdateValueMap(I, ResultReg);
|
|
|
|
|
2008-10-14 23:54:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-09-25 17:05:24 +00:00
|
|
|
}
|
2010-04-13 17:07:06 +00:00
|
|
|
|
|
|
|
// An arbitrary call. Bail.
|
2008-09-25 17:05:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool FastISel::SelectCast(const User *I, unsigned Opcode) {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT SrcVT = TLI.getValueType(I->getOperand(0)->getType());
|
|
|
|
EVT DstVT = TLI.getValueType(I->getType());
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
if (SrcVT == MVT::Other || !SrcVT.isSimple() ||
|
|
|
|
DstVT == MVT::Other || !DstVT.isSimple())
|
2008-08-26 23:46:32 +00:00
|
|
|
// Unhandled type. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2009-03-13 23:53:06 +00:00
|
|
|
// Check if the destination type is legal. Or as a special case,
|
|
|
|
// it may be i1 if we're doing a truncate because that's
|
|
|
|
// easy and somewhat common.
|
|
|
|
if (!TLI.isTypeLegal(DstVT))
|
2009-08-11 20:47:22 +00:00
|
|
|
if (DstVT != MVT::i1 || Opcode != ISD::TRUNCATE)
|
2009-03-13 23:53:06 +00:00
|
|
|
// Unhandled type. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
|
2008-10-03 01:28:47 +00:00
|
|
|
// Check if the source operand is legal. Or as a special case,
|
|
|
|
// it may be i1 if we're doing zero-extension because that's
|
2009-03-13 23:53:06 +00:00
|
|
|
// easy and somewhat common.
|
|
|
|
if (!TLI.isTypeLegal(SrcVT))
|
2009-08-11 20:47:22 +00:00
|
|
|
if (SrcVT != MVT::i1 || Opcode != ISD::ZERO_EXTEND)
|
2008-10-03 01:28:47 +00:00
|
|
|
// Unhandled type. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2009-03-13 23:53:06 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
unsigned InputReg = getRegForValue(I->getOperand(0));
|
2008-08-26 23:46:32 +00:00
|
|
|
if (!InputReg)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2009-03-13 20:42:20 +00:00
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool InputRegIsKill = hasTrivialKill(I->getOperand(0));
|
|
|
|
|
2009-03-13 20:42:20 +00:00
|
|
|
// If the operand is i1, arrange for the high bits in the register to be zero.
|
2009-08-11 20:47:22 +00:00
|
|
|
if (SrcVT == MVT::i1) {
|
2009-08-12 00:36:31 +00:00
|
|
|
SrcVT = TLI.getTypeToTransformTo(I->getContext(), SrcVT);
|
2010-05-11 23:54:07 +00:00
|
|
|
InputReg = FastEmitZExtFromI1(SrcVT.getSimpleVT(), InputReg, InputRegIsKill);
|
2009-03-13 20:42:20 +00:00
|
|
|
if (!InputReg)
|
|
|
|
return false;
|
2010-05-11 23:54:07 +00:00
|
|
|
InputRegIsKill = true;
|
2009-03-13 20:42:20 +00:00
|
|
|
}
|
2009-03-13 23:53:06 +00:00
|
|
|
// If the result is i1, truncate to the target's type for i1 first.
|
2009-08-11 20:47:22 +00:00
|
|
|
if (DstVT == MVT::i1)
|
2009-08-12 00:36:31 +00:00
|
|
|
DstVT = TLI.getTypeToTransformTo(I->getContext(), DstVT);
|
2009-03-13 20:42:20 +00:00
|
|
|
|
2008-08-26 23:46:32 +00:00
|
|
|
unsigned ResultReg = FastEmit_r(SrcVT.getSimpleVT(),
|
|
|
|
DstVT.getSimpleVT(),
|
|
|
|
Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
InputReg, InputRegIsKill);
|
2008-08-26 23:46:32 +00:00
|
|
|
if (!ResultReg)
|
|
|
|
return false;
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, ResultReg);
|
2008-08-26 23:46:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool FastISel::SelectBitCast(const User *I) {
|
2008-08-27 18:10:19 +00:00
|
|
|
// If the bitcast doesn't change the type, just use the operand value.
|
|
|
|
if (I->getType() == I->getOperand(0)->getType()) {
|
2008-09-03 23:12:08 +00:00
|
|
|
unsigned Reg = getRegForValue(I->getOperand(0));
|
2008-08-27 20:41:38 +00:00
|
|
|
if (Reg == 0)
|
|
|
|
return false;
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, Reg);
|
2008-08-27 18:10:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-23 03:31:01 +00:00
|
|
|
// Bitcasts of other values become reg-reg copies or BITCAST operators.
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT SrcVT = TLI.getValueType(I->getOperand(0)->getType());
|
|
|
|
EVT DstVT = TLI.getValueType(I->getType());
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
if (SrcVT == MVT::Other || !SrcVT.isSimple() ||
|
|
|
|
DstVT == MVT::Other || !DstVT.isSimple() ||
|
2008-08-26 23:46:32 +00:00
|
|
|
!TLI.isTypeLegal(SrcVT) || !TLI.isTypeLegal(DstVT))
|
|
|
|
// Unhandled type. Halt "fast" selection and bail.
|
|
|
|
return false;
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
unsigned Op0 = getRegForValue(I->getOperand(0));
|
2008-08-27 18:10:19 +00:00
|
|
|
if (Op0 == 0)
|
|
|
|
// Unhandled operand. Halt "fast" selection and bail.
|
2008-08-26 23:46:32 +00:00
|
|
|
return false;
|
2010-05-11 23:54:07 +00:00
|
|
|
|
|
|
|
bool Op0IsKill = hasTrivialKill(I->getOperand(0));
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-08-27 18:10:19 +00:00
|
|
|
// First, try to perform the bitcast by inserting a reg-reg copy.
|
|
|
|
unsigned ResultReg = 0;
|
|
|
|
if (SrcVT.getSimpleVT() == DstVT.getSimpleVT()) {
|
|
|
|
TargetRegisterClass* SrcClass = TLI.getRegClassFor(SrcVT);
|
|
|
|
TargetRegisterClass* DstClass = TLI.getRegClassFor(DstVT);
|
2010-07-11 05:16:54 +00:00
|
|
|
// Don't attempt a cross-class copy. It will likely fail.
|
|
|
|
if (SrcClass == DstClass) {
|
|
|
|
ResultReg = createResultReg(DstClass);
|
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(Op0);
|
|
|
|
}
|
2008-08-27 18:10:19 +00:00
|
|
|
}
|
2010-11-23 03:31:01 +00:00
|
|
|
|
|
|
|
// If the reg-reg copy failed, select a BITCAST opcode.
|
2008-08-27 18:10:19 +00:00
|
|
|
if (!ResultReg)
|
|
|
|
ResultReg = FastEmit_r(SrcVT.getSimpleVT(), DstVT.getSimpleVT(),
|
2010-11-23 03:31:01 +00:00
|
|
|
ISD::BITCAST, Op0, Op0IsKill);
|
|
|
|
|
2008-08-27 18:10:19 +00:00
|
|
|
if (!ResultReg)
|
2008-08-26 23:46:32 +00:00
|
|
|
return false;
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
UpdateValueMap(I, ResultReg);
|
2008-08-26 23:46:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
bool
|
2010-04-15 01:51:59 +00:00
|
|
|
FastISel::SelectInstruction(const Instruction *I) {
|
2010-04-23 15:29:50 +00:00
|
|
|
// Just before the terminator instruction, insert instructions to
|
|
|
|
// feed PHI nodes in successor blocks.
|
|
|
|
if (isa<TerminatorInst>(I))
|
|
|
|
if (!HandlePHINodesInSuccessorBlocks(I->getParent()))
|
|
|
|
return false;
|
|
|
|
|
2010-04-20 00:48:35 +00:00
|
|
|
DL = I->getDebugLoc();
|
|
|
|
|
2009-12-05 01:27:58 +00:00
|
|
|
// First, try doing target-independent selection.
|
2010-04-20 00:48:35 +00:00
|
|
|
if (SelectOperator(I, I->getOpcode())) {
|
|
|
|
DL = DebugLoc();
|
2009-12-05 01:27:58 +00:00
|
|
|
return true;
|
2010-04-20 00:48:35 +00:00
|
|
|
}
|
2009-12-05 01:27:58 +00:00
|
|
|
|
|
|
|
// Next, try calling the target to attempt to handle the instruction.
|
2010-04-20 00:48:35 +00:00
|
|
|
if (TargetSelectInstruction(I)) {
|
|
|
|
DL = DebugLoc();
|
2009-12-05 01:27:58 +00:00
|
|
|
return true;
|
2010-04-20 00:48:35 +00:00
|
|
|
}
|
2009-12-05 01:27:58 +00:00
|
|
|
|
2010-04-20 00:48:35 +00:00
|
|
|
DL = DebugLoc();
|
2009-12-05 01:27:58 +00:00
|
|
|
return false;
|
2008-09-05 18:18:20 +00:00
|
|
|
}
|
|
|
|
|
2008-10-02 22:15:21 +00:00
|
|
|
/// FastEmitBranch - Emit an unconditional branch to the given block,
|
|
|
|
/// unless it is the immediate (fall-through) successor, and update
|
|
|
|
/// the CFG.
|
|
|
|
void
|
2010-06-17 22:43:56 +00:00
|
|
|
FastISel::FastEmitBranch(MachineBasicBlock *MSucc, DebugLoc DL) {
|
2010-07-10 09:00:22 +00:00
|
|
|
if (FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
|
2008-10-02 22:15:21 +00:00
|
|
|
// The unconditional fall-through case, which needs no instructions.
|
|
|
|
} else {
|
|
|
|
// The unconditional branch case.
|
2010-07-10 09:00:22 +00:00
|
|
|
TII.InsertBranch(*FuncInfo.MBB, MSucc, NULL,
|
|
|
|
SmallVector<MachineOperand, 0>(), DL);
|
2008-10-02 22:15:21 +00:00
|
|
|
}
|
2010-07-10 09:00:22 +00:00
|
|
|
FuncInfo.MBB->addSuccessor(MSucc);
|
2008-10-02 22:15:21 +00:00
|
|
|
}
|
|
|
|
|
2009-09-03 22:53:57 +00:00
|
|
|
/// SelectFNeg - Emit an FNeg operation.
|
|
|
|
///
|
|
|
|
bool
|
2010-04-15 01:51:59 +00:00
|
|
|
FastISel::SelectFNeg(const User *I) {
|
2009-09-03 22:53:57 +00:00
|
|
|
unsigned OpReg = getRegForValue(BinaryOperator::getFNegArgument(I));
|
|
|
|
if (OpReg == 0) return false;
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
bool OpRegIsKill = hasTrivialKill(I);
|
|
|
|
|
2009-09-11 00:36:43 +00:00
|
|
|
// If the target has ISD::FNEG, use it.
|
|
|
|
EVT VT = TLI.getValueType(I->getType());
|
|
|
|
unsigned ResultReg = FastEmit_r(VT.getSimpleVT(), VT.getSimpleVT(),
|
2010-05-11 23:54:07 +00:00
|
|
|
ISD::FNEG, OpReg, OpRegIsKill);
|
2009-09-11 00:36:43 +00:00
|
|
|
if (ResultReg != 0) {
|
|
|
|
UpdateValueMap(I, ResultReg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-11 00:34:46 +00:00
|
|
|
// Bitcast the value to integer, twiddle the sign bit with xor,
|
|
|
|
// and then bitcast it back to floating-point.
|
2009-09-03 22:53:57 +00:00
|
|
|
if (VT.getSizeInBits() > 64) return false;
|
2009-09-11 00:34:46 +00:00
|
|
|
EVT IntVT = EVT::getIntegerVT(I->getContext(), VT.getSizeInBits());
|
|
|
|
if (!TLI.isTypeLegal(IntVT))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
unsigned IntReg = FastEmit_r(VT.getSimpleVT(), IntVT.getSimpleVT(),
|
2010-11-23 03:31:01 +00:00
|
|
|
ISD::BITCAST, OpReg, OpRegIsKill);
|
2009-09-11 00:34:46 +00:00
|
|
|
if (IntReg == 0)
|
|
|
|
return false;
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned IntResultReg = FastEmit_ri_(IntVT.getSimpleVT(), ISD::XOR,
|
|
|
|
IntReg, /*Kill=*/true,
|
2009-09-11 00:34:46 +00:00
|
|
|
UINT64_C(1) << (VT.getSizeInBits()-1),
|
|
|
|
IntVT.getSimpleVT());
|
|
|
|
if (IntResultReg == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ResultReg = FastEmit_r(IntVT.getSimpleVT(), VT.getSimpleVT(),
|
2010-11-23 03:31:01 +00:00
|
|
|
ISD::BITCAST, IntResultReg, /*Kill=*/true);
|
2009-09-03 22:53:57 +00:00
|
|
|
if (ResultReg == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
UpdateValueMap(I, ResultReg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-05 18:18:20 +00:00
|
|
|
bool
|
2010-04-15 01:51:59 +00:00
|
|
|
FastISel::SelectOperator(const User *I, unsigned Opcode) {
|
2008-09-05 18:18:20 +00:00
|
|
|
switch (Opcode) {
|
2009-06-04 22:49:04 +00:00
|
|
|
case Instruction::Add:
|
|
|
|
return SelectBinaryOp(I, ISD::ADD);
|
|
|
|
case Instruction::FAdd:
|
|
|
|
return SelectBinaryOp(I, ISD::FADD);
|
|
|
|
case Instruction::Sub:
|
|
|
|
return SelectBinaryOp(I, ISD::SUB);
|
|
|
|
case Instruction::FSub:
|
2009-09-03 22:53:57 +00:00
|
|
|
// FNeg is currently represented in LLVM IR as a special case of FSub.
|
|
|
|
if (BinaryOperator::isFNeg(I))
|
|
|
|
return SelectFNeg(I);
|
2009-06-04 22:49:04 +00:00
|
|
|
return SelectBinaryOp(I, ISD::FSUB);
|
|
|
|
case Instruction::Mul:
|
|
|
|
return SelectBinaryOp(I, ISD::MUL);
|
|
|
|
case Instruction::FMul:
|
|
|
|
return SelectBinaryOp(I, ISD::FMUL);
|
2008-09-03 23:12:08 +00:00
|
|
|
case Instruction::SDiv:
|
|
|
|
return SelectBinaryOp(I, ISD::SDIV);
|
|
|
|
case Instruction::UDiv:
|
|
|
|
return SelectBinaryOp(I, ISD::UDIV);
|
|
|
|
case Instruction::FDiv:
|
|
|
|
return SelectBinaryOp(I, ISD::FDIV);
|
|
|
|
case Instruction::SRem:
|
|
|
|
return SelectBinaryOp(I, ISD::SREM);
|
|
|
|
case Instruction::URem:
|
|
|
|
return SelectBinaryOp(I, ISD::UREM);
|
|
|
|
case Instruction::FRem:
|
|
|
|
return SelectBinaryOp(I, ISD::FREM);
|
|
|
|
case Instruction::Shl:
|
|
|
|
return SelectBinaryOp(I, ISD::SHL);
|
|
|
|
case Instruction::LShr:
|
|
|
|
return SelectBinaryOp(I, ISD::SRL);
|
|
|
|
case Instruction::AShr:
|
|
|
|
return SelectBinaryOp(I, ISD::SRA);
|
|
|
|
case Instruction::And:
|
|
|
|
return SelectBinaryOp(I, ISD::AND);
|
|
|
|
case Instruction::Or:
|
|
|
|
return SelectBinaryOp(I, ISD::OR);
|
|
|
|
case Instruction::Xor:
|
|
|
|
return SelectBinaryOp(I, ISD::XOR);
|
|
|
|
|
|
|
|
case Instruction::GetElementPtr:
|
|
|
|
return SelectGetElementPtr(I);
|
|
|
|
|
|
|
|
case Instruction::Br: {
|
2010-04-15 01:51:59 +00:00
|
|
|
const BranchInst *BI = cast<BranchInst>(I);
|
2008-09-03 23:12:08 +00:00
|
|
|
|
|
|
|
if (BI->isUnconditional()) {
|
2010-04-15 01:51:59 +00:00
|
|
|
const BasicBlock *LLVMSucc = BI->getSuccessor(0);
|
2010-07-07 16:29:44 +00:00
|
|
|
MachineBasicBlock *MSucc = FuncInfo.MBBMap[LLVMSucc];
|
2010-06-17 22:43:56 +00:00
|
|
|
FastEmitBranch(MSucc, BI->getDebugLoc());
|
2008-09-03 23:12:08 +00:00
|
|
|
return true;
|
2008-08-27 00:31:01 +00:00
|
|
|
}
|
2008-09-03 23:12:08 +00:00
|
|
|
|
|
|
|
// Conditional branches are not handed yet.
|
|
|
|
// Halt "fast" selection and bail.
|
|
|
|
return false;
|
2008-08-13 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
2008-09-05 01:08:41 +00:00
|
|
|
case Instruction::Unreachable:
|
|
|
|
// Nothing to emit.
|
|
|
|
return true;
|
|
|
|
|
2008-09-10 20:11:02 +00:00
|
|
|
case Instruction::Alloca:
|
|
|
|
// FunctionLowering has the static-sized case covered.
|
2010-07-07 16:29:44 +00:00
|
|
|
if (FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(I)))
|
2008-09-10 20:11:02 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// Dynamic-sized alloca is not handled yet.
|
|
|
|
return false;
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-25 17:05:24 +00:00
|
|
|
case Instruction::Call:
|
|
|
|
return SelectCall(I);
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
case Instruction::BitCast:
|
|
|
|
return SelectBitCast(I);
|
|
|
|
|
|
|
|
case Instruction::FPToSI:
|
|
|
|
return SelectCast(I, ISD::FP_TO_SINT);
|
|
|
|
case Instruction::ZExt:
|
|
|
|
return SelectCast(I, ISD::ZERO_EXTEND);
|
|
|
|
case Instruction::SExt:
|
|
|
|
return SelectCast(I, ISD::SIGN_EXTEND);
|
|
|
|
case Instruction::Trunc:
|
|
|
|
return SelectCast(I, ISD::TRUNCATE);
|
|
|
|
case Instruction::SIToFP:
|
|
|
|
return SelectCast(I, ISD::SINT_TO_FP);
|
|
|
|
|
|
|
|
case Instruction::IntToPtr: // Deliberate fall-through.
|
|
|
|
case Instruction::PtrToInt: {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT SrcVT = TLI.getValueType(I->getOperand(0)->getType());
|
|
|
|
EVT DstVT = TLI.getValueType(I->getType());
|
2008-09-03 23:12:08 +00:00
|
|
|
if (DstVT.bitsGT(SrcVT))
|
|
|
|
return SelectCast(I, ISD::ZERO_EXTEND);
|
|
|
|
if (DstVT.bitsLT(SrcVT))
|
|
|
|
return SelectCast(I, ISD::TRUNCATE);
|
|
|
|
unsigned Reg = getRegForValue(I->getOperand(0));
|
|
|
|
if (Reg == 0) return false;
|
|
|
|
UpdateValueMap(I, Reg);
|
|
|
|
return true;
|
|
|
|
}
|
2008-09-23 21:53:34 +00:00
|
|
|
|
2010-04-20 15:00:41 +00:00
|
|
|
case Instruction::PHI:
|
|
|
|
llvm_unreachable("FastISel shouldn't visit PHI nodes!");
|
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
default:
|
|
|
|
// Unhandled instruction. Halt "fast" selection and bail.
|
|
|
|
return false;
|
|
|
|
}
|
2008-08-13 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
2010-07-07 16:29:44 +00:00
|
|
|
FastISel::FastISel(FunctionLoweringInfo &funcInfo)
|
2010-07-10 09:00:22 +00:00
|
|
|
: FuncInfo(funcInfo),
|
2010-07-07 16:29:44 +00:00
|
|
|
MRI(FuncInfo.MF->getRegInfo()),
|
|
|
|
MFI(*FuncInfo.MF->getFrameInfo()),
|
|
|
|
MCP(*FuncInfo.MF->getConstantPool()),
|
|
|
|
TM(FuncInfo.MF->getTarget()),
|
2008-08-22 00:20:26 +00:00
|
|
|
TD(*TM.getTargetData()),
|
|
|
|
TII(*TM.getInstrInfo()),
|
2010-05-05 23:58:35 +00:00
|
|
|
TLI(*TM.getTargetLowering()),
|
2010-07-10 09:00:22 +00:00
|
|
|
TRI(*TM.getRegisterInfo()) {
|
2008-08-20 21:05:57 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 21:51:29 +00:00
|
|
|
FastISel::~FastISel() {}
|
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmit_(MVT, MVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned) {
|
2008-08-13 20:19:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmit_r(MVT, MVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned,
|
|
|
|
unsigned /*Op0*/, bool /*Op0IsKill*/) {
|
2008-08-13 20:19:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-23 03:31:01 +00:00
|
|
|
unsigned FastISel::FastEmit_rr(MVT, MVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned,
|
|
|
|
unsigned /*Op0*/, bool /*Op0IsKill*/,
|
|
|
|
unsigned /*Op1*/, bool /*Op1IsKill*/) {
|
2008-08-13 20:19:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned FastISel::FastEmit_i(MVT, MVT, unsigned, uint64_t /*Imm*/) {
|
2008-08-20 22:45:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmit_f(MVT, MVT,
|
2010-04-15 01:51:59 +00:00
|
|
|
unsigned, const ConstantFP * /*FPImm*/) {
|
2008-08-27 01:09:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmit_ri(MVT, MVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned,
|
|
|
|
unsigned /*Op0*/, bool /*Op0IsKill*/,
|
2008-08-25 23:58:18 +00:00
|
|
|
uint64_t /*Imm*/) {
|
2008-08-21 01:41:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmit_rf(MVT, MVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned,
|
|
|
|
unsigned /*Op0*/, bool /*Op0IsKill*/,
|
2010-04-15 01:51:59 +00:00
|
|
|
const ConstantFP * /*FPImm*/) {
|
2008-08-27 01:09:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmit_rri(MVT, MVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned /*Op0*/, bool /*Op0IsKill*/,
|
|
|
|
unsigned /*Op1*/, bool /*Op1IsKill*/,
|
2008-08-21 01:41:07 +00:00
|
|
|
uint64_t /*Imm*/) {
|
2008-08-20 22:45:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// FastEmit_ri_ - This method is a wrapper of FastEmit_ri. It first tries
|
|
|
|
/// to emit an instruction with an immediate operand using FastEmit_ri.
|
|
|
|
/// If that fails, it materializes the immediate into a register and try
|
|
|
|
/// FastEmit_rr instead.
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned FastISel::FastEmit_ri_(MVT VT, unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint64_t Imm, MVT ImmType) {
|
2008-08-20 22:45:34 +00:00
|
|
|
// First check if immediate type is legal. If not, we can't use the ri form.
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned ResultReg = FastEmit_ri(VT, VT, Opcode, Op0, Op0IsKill, Imm);
|
2008-08-20 22:45:34 +00:00
|
|
|
if (ResultReg != 0)
|
|
|
|
return ResultReg;
|
2008-08-25 23:58:18 +00:00
|
|
|
unsigned MaterialReg = FastEmit_i(ImmType, ImmType, ISD::Constant, Imm);
|
2008-08-21 01:41:07 +00:00
|
|
|
if (MaterialReg == 0)
|
|
|
|
return 0;
|
2010-05-11 23:54:07 +00:00
|
|
|
return FastEmit_rr(VT, VT, Opcode,
|
|
|
|
Op0, Op0IsKill,
|
|
|
|
MaterialReg, /*Kill=*/true);
|
2008-08-21 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 01:09:54 +00:00
|
|
|
/// FastEmit_rf_ - This method is a wrapper of FastEmit_ri. It first tries
|
|
|
|
/// to emit an instruction with a floating-point immediate operand using
|
|
|
|
/// FastEmit_rf. If that fails, it materializes the immediate into a register
|
|
|
|
/// and try FastEmit_rr instead.
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned FastISel::FastEmit_rf_(MVT VT, unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
const ConstantFP *FPImm, MVT ImmType) {
|
2008-08-27 01:09:54 +00:00
|
|
|
// First check if immediate type is legal. If not, we can't use the rf form.
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned ResultReg = FastEmit_rf(VT, VT, Opcode, Op0, Op0IsKill, FPImm);
|
2008-08-27 01:09:54 +00:00
|
|
|
if (ResultReg != 0)
|
|
|
|
return ResultReg;
|
|
|
|
|
|
|
|
// Materialize the constant in a register.
|
|
|
|
unsigned MaterialReg = FastEmit_f(ImmType, ImmType, ISD::ConstantFP, FPImm);
|
|
|
|
if (MaterialReg == 0) {
|
2008-08-27 18:01:42 +00:00
|
|
|
// If the target doesn't have a way to directly enter a floating-point
|
|
|
|
// value into a register, use an alternate approach.
|
|
|
|
// TODO: The current approach only supports floating-point constants
|
|
|
|
// that can be constructed by conversion from integer values. This should
|
|
|
|
// be replaced by code that creates a load from a constant-pool entry,
|
|
|
|
// which will require some target-specific work.
|
2008-08-27 01:09:54 +00:00
|
|
|
const APFloat &Flt = FPImm->getValueAPF();
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT IntVT = TLI.getPointerTy();
|
2008-08-27 01:09:54 +00:00
|
|
|
|
|
|
|
uint64_t x[2];
|
|
|
|
uint32_t IntBitWidth = IntVT.getSizeInBits();
|
2008-10-09 23:00:39 +00:00
|
|
|
bool isExact;
|
|
|
|
(void) Flt.convertToInteger(x, IntBitWidth, /*isSigned=*/true,
|
|
|
|
APFloat::rmTowardZero, &isExact);
|
|
|
|
if (!isExact)
|
2008-08-27 01:09:54 +00:00
|
|
|
return 0;
|
|
|
|
APInt IntVal(IntBitWidth, 2, x);
|
|
|
|
|
|
|
|
unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(),
|
|
|
|
ISD::Constant, IntVal.getZExtValue());
|
|
|
|
if (IntegerReg == 0)
|
|
|
|
return 0;
|
|
|
|
MaterialReg = FastEmit_r(IntVT.getSimpleVT(), VT,
|
2010-05-11 23:54:07 +00:00
|
|
|
ISD::SINT_TO_FP, IntegerReg, /*Kill=*/true);
|
2008-08-27 01:09:54 +00:00
|
|
|
if (MaterialReg == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-11 23:54:07 +00:00
|
|
|
return FastEmit_rr(VT, VT, Opcode,
|
|
|
|
Op0, Op0IsKill,
|
|
|
|
MaterialReg, /*Kill=*/true);
|
2008-08-27 01:09:54 +00:00
|
|
|
}
|
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned FastISel::createResultReg(const TargetRegisterClass* RC) {
|
|
|
|
return MRI.createVirtualRegister(RC);
|
2008-08-20 22:45:34 +00:00
|
|
|
}
|
|
|
|
|
2008-08-13 20:19:35 +00:00
|
|
|
unsigned FastISel::FastEmitInst_(unsigned MachineInstOpcode,
|
2008-08-20 18:09:38 +00:00
|
|
|
const TargetRegisterClass* RC) {
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned ResultReg = createResultReg(RC);
|
2008-08-20 21:05:57 +00:00
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg);
|
2008-08-13 20:19:35 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned FastISel::FastEmitInst_r(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill) {
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned ResultReg = createResultReg(RC);
|
2008-08-20 21:05:57 +00:00
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2008-09-08 08:38:20 +00:00
|
|
|
if (II.getNumDefs() >= 1)
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
|
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill);
|
2008-09-08 08:38:20 +00:00
|
|
|
else {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill);
|
2010-07-11 03:31:05 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(II.ImplicitDefs[0]);
|
2008-09-08 08:38:20 +00:00
|
|
|
}
|
|
|
|
|
2008-08-13 20:19:35 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned FastISel::FastEmitInst_rr(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill) {
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned ResultReg = createResultReg(RC);
|
2008-08-20 21:05:57 +00:00
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2008-09-08 08:38:20 +00:00
|
|
|
if (II.getNumDefs() >= 1)
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addReg(Op1, Op1IsKill * RegState::Kill);
|
2008-09-08 08:38:20 +00:00
|
|
|
else {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addReg(Op1, Op1IsKill * RegState::Kill);
|
2010-07-11 03:31:05 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(II.ImplicitDefs[0]);
|
2008-09-08 08:38:20 +00:00
|
|
|
}
|
2008-08-13 20:19:35 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
2008-08-21 01:41:07 +00:00
|
|
|
|
|
|
|
unsigned FastISel::FastEmitInst_ri(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint64_t Imm) {
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned ResultReg = createResultReg(RC);
|
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
|
|
|
|
2008-09-08 08:38:20 +00:00
|
|
|
if (II.getNumDefs() >= 1)
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addImm(Imm);
|
2008-09-08 08:38:20 +00:00
|
|
|
else {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addImm(Imm);
|
2010-07-11 03:31:05 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(II.ImplicitDefs[0]);
|
2008-09-08 08:38:20 +00:00
|
|
|
}
|
2008-08-21 01:41:07 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
|
|
|
|
2008-08-27 01:09:54 +00:00
|
|
|
unsigned FastISel::FastEmitInst_rf(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
const ConstantFP *FPImm) {
|
2008-08-27 01:09:54 +00:00
|
|
|
unsigned ResultReg = createResultReg(RC);
|
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
|
|
|
|
2008-09-08 08:38:20 +00:00
|
|
|
if (II.getNumDefs() >= 1)
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addFPImm(FPImm);
|
2008-09-08 08:38:20 +00:00
|
|
|
else {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addFPImm(FPImm);
|
2010-07-11 03:31:05 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(II.ImplicitDefs[0]);
|
2008-09-08 08:38:20 +00:00
|
|
|
}
|
2008-08-27 01:09:54 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned FastISel::FastEmitInst_rri(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill,
|
|
|
|
uint64_t Imm) {
|
2008-08-21 01:41:07 +00:00
|
|
|
unsigned ResultReg = createResultReg(RC);
|
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
|
|
|
|
2008-09-08 08:38:20 +00:00
|
|
|
if (II.getNumDefs() >= 1)
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addReg(Op1, Op1IsKill * RegState::Kill)
|
|
|
|
.addImm(Imm);
|
2008-09-08 08:38:20 +00:00
|
|
|
else {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
|
2010-05-11 23:54:07 +00:00
|
|
|
.addReg(Op0, Op0IsKill * RegState::Kill)
|
|
|
|
.addReg(Op1, Op1IsKill * RegState::Kill)
|
|
|
|
.addImm(Imm);
|
2010-07-11 03:31:05 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(II.ImplicitDefs[0]);
|
2008-09-08 08:38:20 +00:00
|
|
|
}
|
2008-08-21 01:41:07 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
2008-08-25 20:20:32 +00:00
|
|
|
|
|
|
|
unsigned FastISel::FastEmitInst_i(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
uint64_t Imm) {
|
|
|
|
unsigned ResultReg = createResultReg(RC);
|
|
|
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
2010-11-23 03:31:01 +00:00
|
|
|
|
2008-09-08 08:38:20 +00:00
|
|
|
if (II.getNumDefs() >= 1)
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg).addImm(Imm);
|
2008-09-08 08:38:20 +00:00
|
|
|
else {
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II).addImm(Imm);
|
2010-07-11 03:31:05 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
|
|
|
|
ResultReg).addReg(II.ImplicitDefs[0]);
|
2008-09-08 08:38:20 +00:00
|
|
|
}
|
2008-08-25 20:20:32 +00:00
|
|
|
return ResultReg;
|
2008-08-25 22:20:39 +00:00
|
|
|
}
|
2008-08-27 22:30:02 +00:00
|
|
|
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastISel::FastEmitInst_extractsubreg(MVT RetVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint32_t Idx) {
|
2009-01-22 09:10:11 +00:00
|
|
|
unsigned ResultReg = createResultReg(TLI.getRegClassFor(RetVT));
|
2010-07-08 16:40:22 +00:00
|
|
|
assert(TargetRegisterInfo::isVirtualRegister(Op0) &&
|
|
|
|
"Cannot yet extract from physregs");
|
2010-07-10 09:00:22 +00:00
|
|
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
|
|
|
|
DL, TII.get(TargetOpcode::COPY), ResultReg)
|
2010-07-08 16:40:22 +00:00
|
|
|
.addReg(Op0, getKillRegState(Op0IsKill), Idx);
|
2008-08-27 22:30:02 +00:00
|
|
|
return ResultReg;
|
|
|
|
}
|
2009-03-13 20:42:20 +00:00
|
|
|
|
|
|
|
/// FastEmitZExtFromI1 - Emit MachineInstrs to compute the value of Op
|
|
|
|
/// with all but the least significant bit set to zero.
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned FastISel::FastEmitZExtFromI1(MVT VT, unsigned Op0, bool Op0IsKill) {
|
|
|
|
return FastEmit_ri(VT, VT, ISD::AND, Op0, Op0IsKill, 1);
|
2009-03-13 20:42:20 +00:00
|
|
|
}
|
2010-04-22 20:46:50 +00:00
|
|
|
|
|
|
|
/// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks.
|
|
|
|
/// Emit code to ensure constants are copied into registers when needed.
|
|
|
|
/// Remember the virtual registers that need to be added to the Machine PHI
|
|
|
|
/// nodes as input. We cannot just directly add them, because expansion
|
|
|
|
/// might result in multiple MBB's for one BB. As such, the start of the
|
|
|
|
/// BB might correspond to a different MBB than the end.
|
|
|
|
bool FastISel::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
|
|
|
|
const TerminatorInst *TI = LLVMBB->getTerminator();
|
|
|
|
|
|
|
|
SmallPtrSet<MachineBasicBlock *, 4> SuccsHandled;
|
2010-07-07 16:29:44 +00:00
|
|
|
unsigned OrigNumPHINodesToUpdate = FuncInfo.PHINodesToUpdate.size();
|
2010-04-22 20:46:50 +00:00
|
|
|
|
|
|
|
// Check successor nodes' PHI nodes that expect a constant to be available
|
|
|
|
// from this block.
|
|
|
|
for (unsigned succ = 0, e = TI->getNumSuccessors(); succ != e; ++succ) {
|
|
|
|
const BasicBlock *SuccBB = TI->getSuccessor(succ);
|
|
|
|
if (!isa<PHINode>(SuccBB->begin())) continue;
|
2010-07-07 16:29:44 +00:00
|
|
|
MachineBasicBlock *SuccMBB = FuncInfo.MBBMap[SuccBB];
|
2010-04-22 20:46:50 +00:00
|
|
|
|
|
|
|
// If this terminator has multiple identical successors (common for
|
|
|
|
// switches), only handle each succ once.
|
|
|
|
if (!SuccsHandled.insert(SuccMBB)) continue;
|
|
|
|
|
|
|
|
MachineBasicBlock::iterator MBBI = SuccMBB->begin();
|
|
|
|
|
|
|
|
// At this point we know that there is a 1-1 correspondence between LLVM PHI
|
|
|
|
// nodes and Machine PHI nodes, but the incoming operands have not been
|
|
|
|
// emitted yet.
|
|
|
|
for (BasicBlock::const_iterator I = SuccBB->begin();
|
|
|
|
const PHINode *PN = dyn_cast<PHINode>(I); ++I) {
|
2010-05-07 01:10:20 +00:00
|
|
|
|
2010-04-22 20:46:50 +00:00
|
|
|
// Ignore dead phi's.
|
|
|
|
if (PN->use_empty()) continue;
|
|
|
|
|
|
|
|
// Only handle legal types. Two interesting things to note here. First,
|
|
|
|
// by bailing out early, we may leave behind some dead instructions,
|
|
|
|
// since SelectionDAG's HandlePHINodesInSuccessorBlocks will insert its
|
|
|
|
// own moves. Second, this check is necessary becuase FastISel doesn't
|
2010-07-02 00:10:16 +00:00
|
|
|
// use CreateRegs to create registers, so it always creates
|
2010-04-22 20:46:50 +00:00
|
|
|
// exactly one register for each non-void instruction.
|
|
|
|
EVT VT = TLI.getValueType(PN->getType(), /*AllowUnknown=*/true);
|
|
|
|
if (VT == MVT::Other || !TLI.isTypeLegal(VT)) {
|
|
|
|
// Promote MVT::i1.
|
|
|
|
if (VT == MVT::i1)
|
|
|
|
VT = TLI.getTypeToTransformTo(LLVMBB->getContext(), VT);
|
|
|
|
else {
|
2010-07-07 16:29:44 +00:00
|
|
|
FuncInfo.PHINodesToUpdate.resize(OrigNumPHINodesToUpdate);
|
2010-04-22 20:46:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB);
|
|
|
|
|
2010-05-07 01:10:20 +00:00
|
|
|
// Set the DebugLoc for the copy. Prefer the location of the operand
|
|
|
|
// if there is one; use the location of the PHI otherwise.
|
|
|
|
DL = PN->getDebugLoc();
|
|
|
|
if (const Instruction *Inst = dyn_cast<Instruction>(PHIOp))
|
|
|
|
DL = Inst->getDebugLoc();
|
|
|
|
|
2010-04-22 20:46:50 +00:00
|
|
|
unsigned Reg = getRegForValue(PHIOp);
|
|
|
|
if (Reg == 0) {
|
2010-07-07 16:29:44 +00:00
|
|
|
FuncInfo.PHINodesToUpdate.resize(OrigNumPHINodesToUpdate);
|
2010-04-22 20:46:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-07-07 16:29:44 +00:00
|
|
|
FuncInfo.PHINodesToUpdate.push_back(std::make_pair(MBBI++, Reg));
|
2010-05-07 01:10:20 +00:00
|
|
|
DL = DebugLoc();
|
2010-04-22 20:46:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|