1 //===-- TargetLowering.cpp - Implement the TargetLowering class -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements the TargetLowering class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetLowering.h"
15 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/CodeGen/SelectionDAG.h"
19 TargetLowering::TargetLowering(TargetMachine &tm)
20 : TM(tm), TD(TM.getTargetData()) {
21 assert(ISD::BUILTIN_OP_END <= 128 &&
22 "Fixed size array in TargetLowering is not large enough!");
24 IsLittleEndian = TD.isLittleEndian();
25 PointerTy = getValueType(TD.getIntPtrType());
26 memset(UnsupportedOps, 0, 128*sizeof(short));
27 memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
30 /// computeRegisterProperties - Once all of the register classes are added,
31 /// this allows us to compute derived properties we expose.
32 void TargetLowering::computeRegisterProperties() {
33 // Everything defaults to one.
34 for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i)
35 NumElementsForVT[i] = 1;
37 // Find the largest integer register class.
38 unsigned LargestIntReg = MVT::i128;
39 for (; RegClassForVT[LargestIntReg] == 0; --LargestIntReg)
40 assert(LargestIntReg != MVT::i1 && "No integer registers defined!");
42 // Every integer value type larger than this largest register takes twice as
43 // many registers to represent as the previous ValueType.
44 unsigned ExpandedReg = LargestIntReg; ++LargestIntReg;
45 for (++ExpandedReg; MVT::isInteger((MVT::ValueType)ExpandedReg);++ExpandedReg)
46 NumElementsForVT[ExpandedReg] = 2*NumElementsForVT[ExpandedReg-1];