aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/TargetLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-07 07:44:53 +0000
committerChris Lattner <sabre@nondot.org>2005-01-07 07:44:53 +0000
commit310968cbbb564c4141d4bd418a746e8103560222 (patch)
treea798db19dfcfae1f9b92356211c7b167e312759c /lib/CodeGen/SelectionDAG/TargetLowering.cpp
parent75c2d0a351cecb222af1da8734a8c1a32f9177a3 (diff)
First draft of new Target interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19324 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/TargetLowering.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
new file mode 100644
index 0000000000..5c45b4bd4d
--- /dev/null
+++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -0,0 +1,48 @@
+//===-- TargetLowering.cpp - Implement the TargetLowering class -----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This implements the TargetLowering class.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Target/TargetLowering.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/CodeGen/SelectionDAG.h"
+using namespace llvm;
+
+TargetLowering::TargetLowering(TargetMachine &tm)
+ : TM(tm), TD(TM.getTargetData()) {
+ assert(ISD::BUILTIN_OP_END <= 128 &&
+ "Fixed size array in TargetLowering is not large enough!");
+
+ IsLittleEndian = TD.isLittleEndian();
+ PointerTy = getValueType(TD.getIntPtrType());
+ memset(UnsupportedOps, 0, ISD::BUILTIN_OP_END*sizeof(short));
+ memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
+}
+
+/// computeRegisterProperties - Once all of the register classes are added,
+/// this allows us to compute derived properties we expose.
+void TargetLowering::computeRegisterProperties() {
+ // Everything defaults to one.
+ for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i)
+ NumElementsForVT[i] = 1;
+
+ // Find the largest integer register class.
+ unsigned LargestIntReg = MVT::i128;
+ for (; RegClassForVT[LargestIntReg] == 0; --LargestIntReg)
+ assert(LargestIntReg != MVT::i1 && "No integer registers defined!");
+
+ // Every integer value type larger than this largest register takes twice as
+ // many registers to represent as the previous ValueType.
+ unsigned ExpandedReg = LargestIntReg; ++LargestIntReg;
+ for (++ExpandedReg; MVT::isInteger((MVT::ValueType)ExpandedReg);++ExpandedReg)
+ NumElementsForVT[ExpandedReg] = 2*NumElementsForVT[ExpandedReg-1];
+}
+