From 8850a1bcef0c2a785f918395fe0a05054914b349 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 27 Mar 2006 22:48:18 +0000 Subject: [PATCH] Add support for decoding iPTR to the right pointer type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27188 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenIntrinsics.h | 3 ++- utils/TableGen/CodeGenTarget.cpp | 20 +++++++++++++++----- utils/TableGen/CodeGenTarget.h | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/utils/TableGen/CodeGenIntrinsics.h b/utils/TableGen/CodeGenIntrinsics.h index 2698836eccd..f779ad31ce9 100644 --- a/utils/TableGen/CodeGenIntrinsics.h +++ b/utils/TableGen/CodeGenIntrinsics.h @@ -21,6 +21,7 @@ namespace llvm { class Record; class RecordKeeper; + class CodeGenTarget; struct CodeGenIntrinsic { Record *TheDef; // The actual record defining this instruction. @@ -45,7 +46,7 @@ namespace llvm { NoMem, ReadArgMem, ReadMem, WriteArgMem, WriteMem } ModRef; - CodeGenIntrinsic(Record *R); + CodeGenIntrinsic(Record *R, CodeGenTarget &CGT); }; /// LoadIntrinsics - Read all of the intrinsics defined in the specified diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index 42864f54f3a..6bee477f317 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -29,8 +29,13 @@ AsmWriterNum("asmwriternum", cl::init(0), /// getValueType - Return the MCV::ValueType that the specified TableGen record /// corresponds to. -MVT::ValueType llvm::getValueType(Record *Rec) { - return (MVT::ValueType)Rec->getValueAsInt("Value"); +MVT::ValueType llvm::getValueType(Record *Rec, const CodeGenTarget *CGT) { + MVT::ValueType VT = (MVT::ValueType)Rec->getValueAsInt("Value"); + if (VT == MVT::iPTR) { + assert(CGT && "Use a pointer type in a place that isn't supported yet!"); + VT = CGT->getPointerType(); + } + return VT; } std::string llvm::getName(MVT::ValueType T) { @@ -355,10 +360,15 @@ ComplexPattern::ComplexPattern(Record *R) { std::vector llvm::LoadIntrinsics(const RecordKeeper &RC) { std::vector I = RC.getAllDerivedDefinitions("Intrinsic"); - return std::vector(I.begin(), I.end()); + + std::vector Result; + CodeGenTarget CGT; + for (unsigned i = 0, e = I.size(); i != e; ++i) + Result.push_back(CodeGenIntrinsic(I[i], CGT)); + return Result; } -CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { +CodeGenIntrinsic::CodeGenIntrinsic(Record *R, CodeGenTarget &CGT) { TheDef = R; std::string DefName = R->getName(); ModRef = WriteMem; @@ -405,7 +415,7 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); ArgTypes.push_back(TyEl->getValueAsString("TypeVal")); - ArgVTs.push_back(getValueType(TyEl->getValueAsDef("VT"))); + ArgVTs.push_back(getValueType(TyEl->getValueAsDef("VT"), &CGT)); ArgTypeDefs.push_back(TyEl); } if (ArgTypes.size() == 0) diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h index 8a4367ad1dd..bedf1bb736f 100644 --- a/utils/TableGen/CodeGenTarget.h +++ b/utils/TableGen/CodeGenTarget.h @@ -27,10 +27,11 @@ namespace llvm { class Record; class RecordKeeper; struct CodeGenRegister; +class CodeGenTarget; /// getValueType - Return the MVT::ValueType that the specified TableGen record /// corresponds to. -MVT::ValueType getValueType(Record *Rec); +MVT::ValueType getValueType(Record *Rec, const CodeGenTarget *CGT = 0); std::ostream &operator<<(std::ostream &OS, MVT::ValueType T); std::string getName(MVT::ValueType T); -- 2.34.1