Skip to content

Commit

Permalink
Merge branch 'master' of http://llvm.org/git/llvm into mico32
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbonn committed Jun 24, 2011
2 parents f49de2a + f5fa52e commit 6237a2c
Show file tree
Hide file tree
Showing 26 changed files with 1,033 additions and 56 deletions.
16 changes: 11 additions & 5 deletions include/llvm/MC/MCRegisterInfo.h
Expand Up @@ -30,7 +30,7 @@ namespace llvm {
/// super-registers of the specific register, e.g. RAX, EAX, are super-registers
/// of AX.
///
struct TargetRegisterDesc {
struct MCRegisterDesc {
const char *Name; // Printable name for the reg (for debugging)
const unsigned *Overlaps; // Overlapping registers, described above
const unsigned *SubRegs; // Sub-register set, described above
Expand All @@ -43,20 +43,26 @@ struct TargetRegisterDesc {
/// to this array so that we can turn register number into a register
/// descriptor.
///
/// Note this class is designed to be a base class of TargetRegisterInfo, which
/// is the interface used by codegen. However, specific targets *should never*
/// specialize this class. MCRegisterInfo should only contain getters to access
/// TableGen generated physical register data. It must not be extended with
/// virtual methods.
///
class MCRegisterInfo {
private:
const TargetRegisterDesc *Desc; // Pointer to the descriptor array
const MCRegisterDesc *Desc; // Pointer to the descriptor array
unsigned NumRegs; // Number of entries in the array

public:
/// InitMCRegisterInfo - Initialize MCRegisterInfo, called by TableGen
/// auto-generated routines. *DO NOT USE*.
void InitMCRegisterInfo(const TargetRegisterDesc *D, unsigned NR) {
void InitMCRegisterInfo(const MCRegisterDesc *D, unsigned NR) {
Desc = D;
NumRegs = NR;
}

const TargetRegisterDesc &operator[](unsigned RegNo) const {
const MCRegisterDesc &operator[](unsigned RegNo) const {
assert(RegNo < NumRegs &&
"Attempting to access record for invalid register number!");
return Desc[RegNo];
Expand All @@ -65,7 +71,7 @@ class MCRegisterInfo {
/// Provide a get method, equivalent to [], but more useful if we have a
/// pointer to this object.
///
const TargetRegisterDesc &get(unsigned RegNo) const {
const MCRegisterDesc &get(unsigned RegNo) const {
return operator[](RegNo);
}

Expand Down
3 changes: 3 additions & 0 deletions include/llvm/Target/TargetRegisterInfo.h
Expand Up @@ -256,6 +256,9 @@ class TargetRegisterClass {
bool isAllocatable() const { return Allocatable; }
};

/// TargetRegisterDesc - It's just an alias of MCRegisterDesc.
typedef MCRegisterDesc TargetRegisterDesc;

/// TargetRegisterInfoDesc - Extra information, not in MCRegisterDesc, about
/// registers. These are used by codegen, not by MC.
struct TargetRegisterInfoDesc {
Expand Down
60 changes: 43 additions & 17 deletions include/llvm/Target/TargetRegistry.h
Expand Up @@ -66,8 +66,7 @@ namespace llvm {

typedef MCAsmInfo *(*AsmInfoCtorFnTy)(const Target &T,
StringRef TT);
typedef MCRegisterInfo *(*RegInfoCtorFnTy)(const Target &T,
StringRef TT);
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(void);
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
const std::string &TT,
const std::string &Features);
Expand Down Expand Up @@ -127,9 +126,9 @@ namespace llvm {
/// registered.
AsmInfoCtorFnTy AsmInfoCtorFn;

/// RegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
/// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
/// if registered.
RegInfoCtorFnTy RegInfoCtorFn;
MCRegInfoCtorFnTy MCRegInfoCtorFn;

/// TargetMachineCtorFn - Construction function for this target's
/// TargetMachine, if registered.
Expand Down Expand Up @@ -240,17 +239,12 @@ namespace llvm {
return AsmInfoCtorFn(*this, Triple);
}

/// createRegInfo - Create a MCRegisterInfo implementation for the specified
/// target triple.
/// createMCRegInfo - Create a MCRegisterInfo implementation.
///
/// \arg Triple - This argument is used to determine the target machine
/// feature set; it should always be provided. Generally this should be
/// either the target triple from the module, or the target triple of the
/// host if that does not exist.
MCRegisterInfo *createRegInfo(StringRef Triple) const {
if (!RegInfoCtorFn)
MCRegisterInfo *createMCRegInfo() const {
if (!MCRegInfoCtorFn)
return 0;
return RegInfoCtorFn(*this, Triple);
return MCRegInfoCtorFn();
}

/// createTargetMachine - Create a target specific machine implementation
Expand Down Expand Up @@ -466,7 +460,7 @@ namespace llvm {
T.AsmInfoCtorFn = Fn;
}

/// RegisterRegInfo - Register a MCRegisterInfo implementation for the
/// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
/// given target.
///
/// Clients are responsible for ensuring that registration doesn't occur
Expand All @@ -475,10 +469,10 @@ namespace llvm {
///
/// @param T - The target being registered.
/// @param Fn - A function to construct a MCRegisterInfo for the target.
static void RegisterRegInfo(Target &T, Target::RegInfoCtorFnTy Fn) {
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) {
// Ignore duplicate registration.
if (!T.RegInfoCtorFn)
T.RegInfoCtorFn = Fn;
if (!T.MCRegInfoCtorFn)
T.MCRegInfoCtorFn = Fn;
}

/// RegisterTargetMachine - Register a TargetMachine implementation for the
Expand Down Expand Up @@ -691,6 +685,38 @@ namespace llvm {
}
};

/// RegisterMCRegInfo - Helper template for registering a target register info
/// implementation. This invokes the static "Create" method on the class to
/// actually do the construction. Usage:
///
/// extern "C" void LLVMInitializeFooTarget() {
/// extern Target TheFooTarget;
/// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
/// }
template<class MCRegisterInfoImpl>
struct RegisterMCRegInfo {
RegisterMCRegInfo(Target &T) {
TargetRegistry::RegisterMCRegInfo(T, &Allocator);
}
private:
static MCRegisterInfo *Allocator() {
return new MCRegisterInfoImpl();
}
};

/// RegisterMCRegInfoFn - Helper template for registering a target register
/// info implementation. This invokes the specified function to do the
/// construction. Usage:
///
/// extern "C" void LLVMInitializeFooTarget() {
/// extern Target TheFooTarget;
/// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
/// }
struct RegisterMCRegInfoFn {
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn) {
TargetRegistry::RegisterMCRegInfo(T, Fn);
}
};

/// RegisterTargetMachine - Helper template for registering a target machine
/// implementation, for use in the target machine initialization
Expand Down
3 changes: 2 additions & 1 deletion lib/MC/MachObjectWriter.cpp
Expand Up @@ -1098,7 +1098,8 @@ bool MachObjectWriter::getARMFixupKindMachOInfo(unsigned Kind,
RelocType = unsigned(macho::RIT_ARM_ThumbBranch22Bit);
Log2Size = llvm::Log2_32(2);
return true;


case ARM::fixup_t2_uncondbranch:
case ARM::fixup_arm_thumb_bl:
case ARM::fixup_arm_thumb_blx:
RelocType = unsigned(macho::RIT_ARM_ThumbBranch22Bit);
Expand Down
9 changes: 6 additions & 3 deletions lib/Target/ARM/ARMAsmBackend.cpp
Expand Up @@ -174,7 +174,8 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
Value >>= 16;
// Fallthrough
case ARM::fixup_t2_movw_lo16:
case ARM::fixup_t2_movt_hi16_pcrel:
case ARM::fixup_t2_movt_hi16_pcrel: //FIXME: Shouldn't this be shifted like
// the other hi16 fixup?
case ARM::fixup_t2_movw_lo16_pcrel: {
unsigned Hi4 = (Value & 0xF000) >> 12;
unsigned i = (Value & 0x800) >> 11;
Expand All @@ -184,8 +185,10 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
// inst{26} = i;
// inst{14-12} = Mid3;
// inst{7-0} = Lo8;
assert ((((int64_t)Value) >= -0x8000) && (((int64_t)Value) <= 0x7fff) &&
"Out of range pc-relative fixup value!");
// The value comes in as the whole thing, not just the portion required
// for this fixup, so we need to mask off the bits not handled by this
// portion (lo vs. hi).
Value &= 0xffff;
Value = (Hi4 << 16) | (i << 26) | (Mid3 << 12) | (Lo8);
uint64_t swapped = (Value & 0xFFFF0000) >> 16;
swapped |= (Value & 0x0000FFFF) << 16;
Expand Down
105 changes: 104 additions & 1 deletion lib/Target/ARM/ARMISelLowering.cpp
Expand Up @@ -506,6 +506,9 @@ ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
setTargetDAGCombine(ISD::VECTOR_SHUFFLE);
setTargetDAGCombine(ISD::INSERT_VECTOR_ELT);
setTargetDAGCombine(ISD::STORE);
setTargetDAGCombine(ISD::FP_TO_SINT);
setTargetDAGCombine(ISD::FP_TO_UINT);
setTargetDAGCombine(ISD::FDIV);
}

computeRegisterProperties();
Expand Down Expand Up @@ -6479,7 +6482,104 @@ static SDValue PerformVDUPLANECombine(SDNode *N,
return DCI.DAG.getNode(ISD::BITCAST, N->getDebugLoc(), VT, Op);
}

/// getVShiftImm - Check if this is a valid build_vector for the immediate
// isConstVecPow2 - Return true if each vector element is a power of 2, all
// elements are the same constant, C, and Log2(C) ranges from 1 to 32.
static bool isConstVecPow2(SDValue ConstVec, bool isSigned, uint64_t &C)
{
integerPart c0, cN;
for (unsigned I = 0, E = ConstVec.getValueType().getVectorNumElements();
I != E; I++) {
ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(ConstVec.getOperand(I));
if (!C)
return false;

bool isExact;
APFloat APF = C->getValueAPF();
if (APF.convertToInteger(&cN, 64, isSigned, APFloat::rmTowardZero, &isExact)
!= APFloat::opOK || !isExact)
return false;

c0 = (I == 0) ? cN : c0;
if (!isPowerOf2_64(cN) || c0 != cN || Log2_64(c0) < 1 || Log2_64(c0) > 32)
return false;
}
C = c0;
return true;
}

/// PerformVCVTCombine - VCVT (floating-point to fixed-point, Advanced SIMD)
/// can replace combinations of VMUL and VCVT (floating-point to integer)
/// when the VMUL has a constant operand that is a power of 2.
///
/// Example (assume d17 = <float 8.000000e+00, float 8.000000e+00>):
/// vmul.f32 d16, d17, d16
/// vcvt.s32.f32 d16, d16
/// becomes:
/// vcvt.s32.f32 d16, d16, #3
static SDValue PerformVCVTCombine(SDNode *N,
TargetLowering::DAGCombinerInfo &DCI,
const ARMSubtarget *Subtarget) {
SelectionDAG &DAG = DCI.DAG;
SDValue Op = N->getOperand(0);

if (!Subtarget->hasNEON() || !Op.getValueType().isVector() ||
Op.getOpcode() != ISD::FMUL)
return SDValue();

uint64_t C;
SDValue N0 = Op->getOperand(0);
SDValue ConstVec = Op->getOperand(1);
bool isSigned = N->getOpcode() == ISD::FP_TO_SINT;

if (ConstVec.getOpcode() != ISD::BUILD_VECTOR ||
!isConstVecPow2(ConstVec, isSigned, C))
return SDValue();

unsigned IntrinsicOpcode = isSigned ? Intrinsic::arm_neon_vcvtfp2fxs :
Intrinsic::arm_neon_vcvtfp2fxu;
return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, N->getDebugLoc(),
N->getValueType(0),
DAG.getConstant(IntrinsicOpcode, MVT::i32), N0,
DAG.getConstant(Log2_64(C), MVT::i32));
}

/// PerformVDIVCombine - VCVT (fixed-point to floating-point, Advanced SIMD)
/// can replace combinations of VCVT (integer to floating-point) and VDIV
/// when the VDIV has a constant operand that is a power of 2.
///
/// Example (assume d17 = <float 8.000000e+00, float 8.000000e+00>):
/// vcvt.f32.s32 d16, d16
/// vdiv.f32 d16, d17, d16
/// becomes:
/// vcvt.f32.s32 d16, d16, #3
static SDValue PerformVDIVCombine(SDNode *N,
TargetLowering::DAGCombinerInfo &DCI,
const ARMSubtarget *Subtarget) {
SelectionDAG &DAG = DCI.DAG;
SDValue Op = N->getOperand(0);
unsigned OpOpcode = Op.getNode()->getOpcode();

if (!Subtarget->hasNEON() || !N->getValueType(0).isVector() ||
(OpOpcode != ISD::SINT_TO_FP && OpOpcode != ISD::UINT_TO_FP))
return SDValue();

uint64_t C;
SDValue ConstVec = N->getOperand(1);
bool isSigned = OpOpcode == ISD::SINT_TO_FP;

if (ConstVec.getOpcode() != ISD::BUILD_VECTOR ||
!isConstVecPow2(ConstVec, isSigned, C))
return SDValue();

unsigned IntrinsicOpcode = isSigned ? Intrinsic::arm_neon_vcvtfxs2fp :
Intrinsic::arm_neon_vcvtfxu2fp;
return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, N->getDebugLoc(),
Op.getValueType(),
DAG.getConstant(IntrinsicOpcode, MVT::i32),
Op.getOperand(0), DAG.getConstant(Log2_64(C), MVT::i32));
}

/// Getvshiftimm - Check if this is a valid build_vector for the immediate
/// operand of a vector shift operation, where all the elements of the
/// build_vector must have the same constant integer value.
static bool getVShiftImm(SDValue Op, unsigned ElementBits, int64_t &Cnt) {
Expand Down Expand Up @@ -6868,6 +6968,9 @@ SDValue ARMTargetLowering::PerformDAGCombine(SDNode *N,
case ISD::INSERT_VECTOR_ELT: return PerformInsertEltCombine(N, DCI);
case ISD::VECTOR_SHUFFLE: return PerformVECTOR_SHUFFLECombine(N, DCI.DAG);
case ARMISD::VDUPLANE: return PerformVDUPLANECombine(N, DCI);
case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT: return PerformVCVTCombine(N, DCI, Subtarget);
case ISD::FDIV: return PerformVDIVCombine(N, DCI, Subtarget);
case ISD::INTRINSIC_WO_CHAIN: return PerformIntrinsicCombine(N, DCI.DAG);
case ISD::SHL:
case ISD::SRA:
Expand Down
5 changes: 1 addition & 4 deletions lib/Target/Mips/MipsISelLowering.cpp
Expand Up @@ -1911,7 +1911,7 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
if (LoadSymAddr) {
// Load callee address
Callee = DAG.getNode(MipsISD::WrapperPIC, dl, MVT::i32, Callee);
SDValue LoadValue = DAG.getLoad(MVT::i32, dl, Chain, Callee,
SDValue LoadValue = DAG.getLoad(MVT::i32, dl, DAG.getEntryNode(), Callee,
MachinePointerInfo::getGOT(),
false, false, 0);

Expand All @@ -1921,9 +1921,6 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
Callee = DAG.getNode(ISD::ADD, dl, MVT::i32, LoadValue, Lo);
} else
Callee = LoadValue;

// Use chain output from LoadValue
Chain = LoadValue.getValue(1);
}

// copy to T9
Expand Down

0 comments on commit 6237a2c

Please sign in to comment.