Clear the whole array, always.
[oota-llvm.git] / lib / CodeGen / SelectionDAG / TargetLowering.cpp
1 //===-- TargetLowering.cpp - Implement the TargetLowering class -----------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This implements the TargetLowering class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetLowering.h"
15 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/CodeGen/SelectionDAG.h"
17 using namespace llvm;
18
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!");
23
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*));
28 }
29
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;
36   
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!");
41
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];
47 }
48