Changes in directory llvm/utils/TableGen:
IntrinsicEmitter.cpp updated: 1.15 -> 1.16 CodeGenIntrinsics.h updated: 1.6 -> 1.7 CodeGenTarget.cpp updated: 1.57 -> 1.58 --- Log message: Move CodeGenIntrinsic implementation to CodeGenTarget.cpp with the rest of the CodeGen* implementations. Parse the MVT::ValueType for each operand of the intrinsics. --- Diffs of the changes: (+89 -83) CodeGenIntrinsics.h | 4 ++ CodeGenTarget.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ IntrinsicEmitter.cpp | 83 ------------------------------------------------- 3 files changed, 89 insertions(+), 83 deletions(-) Index: llvm/utils/TableGen/IntrinsicEmitter.cpp diff -u llvm/utils/TableGen/IntrinsicEmitter.cpp:1.15 llvm/utils/TableGen/IntrinsicEmitter.cpp:1.16 --- llvm/utils/TableGen/IntrinsicEmitter.cpp:1.15 Thu Mar 23 19:13:55 2006 +++ llvm/utils/TableGen/IntrinsicEmitter.cpp Fri Mar 24 13:49:31 2006 @@ -18,89 +18,6 @@ using namespace llvm; //===----------------------------------------------------------------------===// -// CodeGenIntrinsic Implementation -//===----------------------------------------------------------------------===// - -std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const RecordKeeper &RC) { - std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic"); - return std::vector<CodeGenIntrinsic>(I.begin(), I.end()); -} - -CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { - std::string DefName = R->getName(); - ModRef = WriteMem; - - if (DefName.size() <= 4 || - std::string(DefName.begin(), DefName.begin()+4) != "int_") - throw "Intrinsic '" + DefName + "' does not start with 'int_'!"; - EnumName = std::string(DefName.begin()+4, DefName.end()); - if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field. - GCCBuiltinName = R->getValueAsString("GCCBuiltinName"); - TargetPrefix = R->getValueAsString("TargetPrefix"); - Name = R->getValueAsString("LLVMName"); - if (Name == "") { - // If an explicit name isn't specified, derive one from the DefName. - Name = "llvm."; - for (unsigned i = 0, e = EnumName.size(); i != e; ++i) - if (EnumName[i] == '_') - Name += '.'; - else - Name += EnumName[i]; - } else { - // Verify it starts with "llvm.". - if (Name.size() <= 5 || - std::string(Name.begin(), Name.begin()+5) != "llvm.") - throw "Intrinsic '" + DefName + "'s name does not start with 'llvm.'!"; - } - - // If TargetPrefix is specified, make sure that Name starts with - // "llvm.<targetprefix>.". - if (!TargetPrefix.empty()) { - if (Name.size() < 6+TargetPrefix.size() || - std::string(Name.begin()+5, Name.begin()+6+TargetPrefix.size()) - != (TargetPrefix+".")) - throw "Intrinsic '" + DefName + "' does not start with 'llvm." + - TargetPrefix + ".'!"; - } - - // Parse the list of argument types. - ListInit *TypeList = R->getValueAsListInit("Types"); - for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { - DefInit *DI = dynamic_cast<DefInit*>(TypeList->getElement(i)); - assert(DI && "Invalid list type!"); - Record *TyEl = DI->getDef(); - assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); - ArgTypes.push_back(TyEl->getValueAsString("TypeVal")); - ArgTypeDefs.push_back(TyEl); - } - if (ArgTypes.size() == 0) - throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!"; - - // Parse the intrinsic properties. - ListInit *PropList = R->getValueAsListInit("Properties"); - for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { - DefInit *DI = dynamic_cast<DefInit*>(PropList->getElement(i)); - assert(DI && "Invalid list type!"); - Record *Property = DI->getDef(); - assert(Property->isSubClassOf("IntrinsicProperty") && - "Expected a property!"); - - if (Property->getName() == "InstrNoMem") - ModRef = NoMem; - else if (Property->getName() == "InstrReadArgMem") - ModRef = ReadArgMem; - else if (Property->getName() == "IntrReadMem") - ModRef = ReadMem; - else if (Property->getName() == "InstrWriteArgMem") - ModRef = WriteArgMem; - else if (Property->getName() == "IntrWriteMem") - ModRef = WriteMem; - else - assert(0 && "Unknown property!"); - } -} - -//===----------------------------------------------------------------------===// // IntrinsicEmitter Implementation //===----------------------------------------------------------------------===// Index: llvm/utils/TableGen/CodeGenIntrinsics.h diff -u llvm/utils/TableGen/CodeGenIntrinsics.h:1.6 llvm/utils/TableGen/CodeGenIntrinsics.h:1.7 --- llvm/utils/TableGen/CodeGenIntrinsics.h:1.6 Tue Mar 14 19:33:26 2006 +++ llvm/utils/TableGen/CodeGenIntrinsics.h Fri Mar 24 13:49:31 2006 @@ -16,6 +16,7 @@ #include <string> #include <vector> +#include "llvm/CodeGen/ValueTypes.h" namespace llvm { class Record; @@ -32,6 +33,9 @@ /// of the arguments. These are things like Type::UIntTyID. std::vector<std::string> ArgTypes; + /// ArgVTs - The MVT::ValueType for each argument type. + std::vector<MVT::ValueType> ArgVTs; + /// ArgTypeDefs - The records for each argument type. /// std::vector<Record*> ArgTypeDefs; Index: llvm/utils/TableGen/CodeGenTarget.cpp diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.57 llvm/utils/TableGen/CodeGenTarget.cpp:1.58 --- llvm/utils/TableGen/CodeGenTarget.cpp:1.57 Sun Mar 19 01:57:34 2006 +++ llvm/utils/TableGen/CodeGenTarget.cpp Fri Mar 24 13:49:31 2006 @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "CodeGenTarget.h" +#include "CodeGenIntrinsics.h" #include "Record.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" @@ -348,3 +349,87 @@ RootNodes = R->getValueAsListOfDefs("RootNodes"); } +//===----------------------------------------------------------------------===// +// CodeGenIntrinsic Implementation +//===----------------------------------------------------------------------===// + +std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const RecordKeeper &RC) { + std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic"); + return std::vector<CodeGenIntrinsic>(I.begin(), I.end()); +} + +CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { + std::string DefName = R->getName(); + ModRef = WriteMem; + + if (DefName.size() <= 4 || + std::string(DefName.begin(), DefName.begin()+4) != "int_") + throw "Intrinsic '" + DefName + "' does not start with 'int_'!"; + EnumName = std::string(DefName.begin()+4, DefName.end()); + if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field. + GCCBuiltinName = R->getValueAsString("GCCBuiltinName"); + TargetPrefix = R->getValueAsString("TargetPrefix"); + Name = R->getValueAsString("LLVMName"); + if (Name == "") { + // If an explicit name isn't specified, derive one from the DefName. + Name = "llvm."; + for (unsigned i = 0, e = EnumName.size(); i != e; ++i) + if (EnumName[i] == '_') + Name += '.'; + else + Name += EnumName[i]; + } else { + // Verify it starts with "llvm.". + if (Name.size() <= 5 || + std::string(Name.begin(), Name.begin()+5) != "llvm.") + throw "Intrinsic '" + DefName + "'s name does not start with 'llvm.'!"; + } + + // If TargetPrefix is specified, make sure that Name starts with + // "llvm.<targetprefix>.". + if (!TargetPrefix.empty()) { + if (Name.size() < 6+TargetPrefix.size() || + std::string(Name.begin()+5, Name.begin()+6+TargetPrefix.size()) + != (TargetPrefix+".")) + throw "Intrinsic '" + DefName + "' does not start with 'llvm." + + TargetPrefix + ".'!"; + } + + // Parse the list of argument types. + ListInit *TypeList = R->getValueAsListInit("Types"); + for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { + DefInit *DI = dynamic_cast<DefInit*>(TypeList->getElement(i)); + assert(DI && "Invalid list type!"); + Record *TyEl = DI->getDef(); + assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); + ArgTypes.push_back(TyEl->getValueAsString("TypeVal")); + + ArgVTs.push_back(getValueType(TyEl->getValueAsDef("VT"))); + ArgTypeDefs.push_back(TyEl); + } + if (ArgTypes.size() == 0) + throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!"; + + // Parse the intrinsic properties. + ListInit *PropList = R->getValueAsListInit("Properties"); + for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { + DefInit *DI = dynamic_cast<DefInit*>(PropList->getElement(i)); + assert(DI && "Invalid list type!"); + Record *Property = DI->getDef(); + assert(Property->isSubClassOf("IntrinsicProperty") && + "Expected a property!"); + + if (Property->getName() == "InstrNoMem") + ModRef = NoMem; + else if (Property->getName() == "InstrReadArgMem") + ModRef = ReadArgMem; + else if (Property->getName() == "IntrReadMem") + ModRef = ReadMem; + else if (Property->getName() == "InstrWriteArgMem") + ModRef = WriteArgMem; + else if (Property->getName() == "IntrWriteMem") + ModRef = WriteMem; + else + assert(0 && "Unknown property!"); + } +} _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits