[llvm-commits] [llvm] r63765 - in /llvm/trunk: ./ include/llvm/ include/llvm/Target/ lib/AsmParser/ lib/CodeGen/SelectionDAG/ lib/Target/ lib/VMCore/ utils/TableGen/
Dale Johannesen
dalej at apple.com
Wed Feb 4 13:48:36 PST 2009
This seems to have broken both llvm-gcc and clang. Could you look?
On Feb 4, 2009, at 11:47 AMPST, Nate Begeman wrote:
> Author: sampo
> Date: Wed Feb 4 13:47:21 2009
> New Revision: 63765
>
> URL: http://llvm.org/viewvc/llvm-project?rev=63765&view=rev
> Log:
> New feature: add support for target intrinsics being defined in the
> target directories themselves. This also means that VMCore no longer
> needs to know about every target's list of intrinsics. Future work
> will include converting the PowerPC target to this interface as an
> example implementation.
>
> Added:
> llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h
> llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp
> Modified:
> llvm/trunk/Makefile.rules
> llvm/trunk/include/llvm/Function.h
> llvm/trunk/include/llvm/Intrinsics.h
> llvm/trunk/include/llvm/Intrinsics.td
> llvm/trunk/include/llvm/Module.h
> llvm/trunk/include/llvm/Target/TargetMachine.h
> llvm/trunk/lib/AsmParser/LLParser.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
> llvm/trunk/lib/VMCore/AutoUpgrade.cpp
> llvm/trunk/lib/VMCore/Function.cpp
> llvm/trunk/lib/VMCore/Module.cpp
> llvm/trunk/lib/VMCore/Verifier.cpp
> llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
> llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
> llvm/trunk/utils/TableGen/CodeGenIntrinsics.h
> llvm/trunk/utils/TableGen/CodeGenTarget.cpp
> llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
> llvm/trunk/utils/TableGen/IntrinsicEmitter.h
> llvm/trunk/utils/TableGen/TableGen.cpp
>
> Modified: llvm/trunk/Makefile.rules
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/Makefile.rules (original)
> +++ llvm/trunk/Makefile.rules Wed Feb 4 13:47:21 2009
> @@ -1346,6 +1346,11 @@
> $(Echo) "Building $(<F) calling convention information with tblgen"
> $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
>
> +$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
> +$(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
> + $(Echo) "Building $(<F) calling convention information with tblgen"
> + $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
> +
> clean-local::
> -$(Verb) $(RM) -f $(INCFiles)
>
>
> Modified: llvm/trunk/include/llvm/Function.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/Function.h (original)
> +++ llvm/trunk/include/llvm/Function.h Wed Feb 4 13:47:21 2009
> @@ -129,7 +129,7 @@
> /// The particular intrinsic functions which correspond to this
> value are
> /// defined in llvm/Intrinsics.h.
> ///
> - unsigned getIntrinsicID(bool noAssert = false) const;
> + unsigned getIntrinsicID() const;
> bool isIntrinsic() const { return getIntrinsicID() != 0; }
>
> /// getCallingConv()/setCallingConv(uint) - These method get and
> set the
>
> Modified: llvm/trunk/include/llvm/Intrinsics.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/Intrinsics.h (original)
> +++ llvm/trunk/include/llvm/Intrinsics.h Wed Feb 4 13:47:21 2009
> @@ -63,6 +63,9 @@
> /// intrinsic.
> Function *getDeclaration(Module *M, ID id, const Type **Tys = 0,
> unsigned numTys = 0);
> +
> + /// Map a GCC builtin name to an intrinsic ID.
> + ID getIntrinsicForGCCBuiltin(const char *Prefix, const char
> *BuiltinName);
>
> } // End Intrinsic namespace
>
>
> Modified: llvm/trunk/include/llvm/Intrinsics.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/Intrinsics.td (original)
> +++ llvm/trunk/include/llvm/Intrinsics.td Wed Feb 4 13:47:21 2009
> @@ -144,6 +144,8 @@
> list<LLVMType> RetTypes = ret_types;
> list<LLVMType> ParamTypes = param_types;
> list<IntrinsicProperty> Properties = properties;
> +
> + bit isTarget = 0;
> }
>
> /// GCCBuiltin - If this intrinsic exactly corresponds to a GCC
> builtin, this
>
> Modified: llvm/trunk/include/llvm/Module.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/Module.h (original)
> +++ llvm/trunk/include/llvm/Module.h Wed Feb 4 13:47:21 2009
> @@ -213,6 +213,10 @@
> Constant *getOrInsertFunction(const std::string &Name, const Type
> *RetTy, ...)
> END_WITH_NULL;
>
> + Constant *getOrInsertTargetIntrinsic(const std::string &Name,
> + const FunctionType *Ty,
> + AttrListPtr AttributeList);
> +
> /// getFunction - Look up the specified function in the module
> symbol table.
> /// If it does not exist, return null.
> Function *getFunction(const std::string &Name) const;
>
> Added: llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h?rev=63765&view=auto
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h (added)
> +++ llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h Wed Feb 4
> 13:47:21 2009
> @@ -0,0 +1,48 @@
> +//===-- llvm/Target/TargetIntrinsicInfo.h - Instruction Info ----*-
> C++ -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open
> Source
> +// License. See LICENSE.TXT for details.
> +//
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +//
> +// This file describes the target intrinsic instructions to the
> code generator.
> +//
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +
> +#ifndef LLVM_TARGET_TARGETINTRINSICINFO_H
> +#define LLVM_TARGET_TARGETINTRINSICINFO_H
> +
> +namespace llvm {
> +
> +class Function;
> +class Module;
> +
> +
> //---------------------------------------------------------------------------
> +///
> +/// TargetIntrinsicInfo - Interface to description of machine
> instruction set
> +///
> +class TargetIntrinsicInfo {
> +
> + const char **Intrinsics; // Raw array to allow
> static init'n
> + unsigned NumIntrinsics; // Number of entries in
> the desc array
> +
> + TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT
> IMPLEMENT
> + void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT
> +public:
> + TargetIntrinsicInfo(const char **desc, unsigned num);
> + virtual ~TargetIntrinsicInfo();
> +
> + unsigned getNumIntrinsics() const { return NumIntrinsics; }
> +
> + virtual Function *getDeclaration(Module *M, const char
> *BuiltinName) const {
> + return 0;
> + }
> +
> + virtual unsigned getIntrinsicID(Function *F) const { return 0; }
> +};
> +
> +} // End llvm namespace
> +
> +#endif
>
> Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetMachine.h Wed Feb 4
> 13:47:21 2009
> @@ -23,6 +23,7 @@
> class TargetData;
> class TargetSubtarget;
> class TargetInstrInfo;
> +class TargetIntrinsicInfo;
> class TargetJITInfo;
> class TargetLowering;
> class TargetFrameInfo;
> @@ -118,7 +119,6 @@
> virtual TargetLowering *getTargetLowering() const
> { return 0; }
> virtual const TargetData *getTargetData() const
> { return 0; }
>
> -
> /// getTargetAsmInfo - Return target specific asm information.
> ///
> const TargetAsmInfo *getTargetAsmInfo() const {
> @@ -141,6 +141,11 @@
> /// details of graph coloring register allocation removed from it.
> ///
> virtual const TargetRegisterInfo *getRegisterInfo() const { return
> 0; }
> +
> + /// getIntrinsicInfo - If intrinsic information is available,
> return it. If
> + /// not, return null.
> + ///
> + virtual const TargetIntrinsicInfo *getIntrinsicInfo() const
> { return 0; }
>
> /// getJITInfo - If this target supports a JIT, return information
> for it,
> /// otherwise return null.
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Feb 4 13:47:21 2009
> @@ -2949,15 +2949,6 @@
> Value *Callee;
> if (ConvertValIDToValue(PFTy, CalleeID, Callee, PFS)) return true;
>
> - // Check for call to invalid intrinsic to avoid crashing later.
> - if (Function *F = dyn_cast<Function>(Callee)) {
> - if (F->hasName() && F->getNameLen() >= 5 &&
> - !strncmp(F->getValueName()->getKeyData(), "llvm.", 5) &&
> - !F->getIntrinsicID(true))
> - return Error(CallLoc, "Call to invalid LLVM intrinsic
> function '" +
> - F->getNameStr() + "'");
> - }
> -
> // FIXME: In LLVM 3.0, stop accepting zext, sext and inreg as
> optional
> // function attributes.
> unsigned ObsoleteFuncAttrs = Attribute::ZExt|Attribute::SExt|
> Attribute::InReg;
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
> (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Wed
> Feb 4 13:47:21 2009
> @@ -43,6 +43,7 @@
> #include "llvm/Target/TargetData.h"
> #include "llvm/Target/TargetFrameInfo.h"
> #include "llvm/Target/TargetInstrInfo.h"
> +#include "llvm/Target/TargetIntrinsicInfo.h"
> #include "llvm/Target/TargetLowering.h"
> #include "llvm/Target/TargetMachine.h"
> #include "llvm/Target/TargetOptions.h"
> @@ -4426,6 +4427,14 @@
> const char *RenameFn = 0;
> if (Function *F = I.getCalledFunction()) {
> if (F->isDeclaration()) {
> + const TargetIntrinsicInfo *II =
> TLI.getTargetMachine().getIntrinsicInfo();
> + if (II) {
> + if (unsigned IID = II->getIntrinsicID(F)) {
> + RenameFn = visitIntrinsicCall(I, IID);
> + if (!RenameFn)
> + return;
> + }
> + }
> if (unsigned IID = F->getIntrinsicID()) {
> RenameFn = visitIntrinsicCall(I, IID);
> if (!RenameFn)
>
> Added: llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp?rev=63765&view=auto
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp (added)
> +++ llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp Wed Feb 4
> 13:47:21 2009
> @@ -0,0 +1,22 @@
> +//===-- TargetIntrinsicInfo.cpp - Target Instruction Information
> ----------===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open
> Source
> +// License. See LICENSE.TXT for details.
> +//
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +//
> +// This file implements the TargetIntrinsicInfo class.
> +//
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +
> +#include "llvm/Target/TargetIntrinsicInfo.h"
> +using namespace llvm;
> +
> +TargetIntrinsicInfo::TargetIntrinsicInfo(const char **desc,
> unsigned count)
> + : Intrinsics(desc), NumIntrinsics(count) {
> +}
> +
> +TargetIntrinsicInfo::~TargetIntrinsicInfo() {
> +}
>
> Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
> +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Wed Feb 4 13:47:21 2009
> @@ -217,7 +217,7 @@
> // Upgrade intrinsic attributes. This does not change the function.
> if (NewFn)
> F = NewFn;
> - if (unsigned id = F->getIntrinsicID(true))
> + if (unsigned id = F->getIntrinsicID())
> F->setAttributes(Intrinsic::getAttributes((Intrinsic::ID)id));
> return Upgraded;
> }
>
> Modified: llvm/trunk/lib/VMCore/Function.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Function.cpp (original)
> +++ llvm/trunk/lib/VMCore/Function.cpp Wed Feb 4 13:47:21 2009
> @@ -175,7 +175,7 @@
> ParentModule->getFunctionList().push_back(this);
>
> // Ensure intrinsics have the right parameter attributes.
> - if (unsigned IID = getIntrinsicID(true))
> + if (unsigned IID = getIntrinsicID())
> setAttributes(Intrinsic::getAttributes(Intrinsic::ID(IID)));
>
> }
> @@ -304,7 +304,7 @@
> /// particular intrinsic functions which correspond to this value
> are defined in
> /// llvm/Intrinsics.h.
> ///
> -unsigned Function::getIntrinsicID(bool noAssert) const {
> +unsigned Function::getIntrinsicID() const {
> const ValueName *ValName = this->getValueName();
> if (!ValName)
> return 0;
> @@ -315,12 +315,9 @@
> || Name[2] != 'v' || Name[3] != 'm')
> return 0; // All intrinsics start with 'llvm.'
>
> - assert((Len != 5 || noAssert) && "'llvm.' is an invalid intrinsic
> name!");
> -
> #define GET_FUNCTION_RECOGNIZER
> #include "llvm/Intrinsics.gen"
> #undef GET_FUNCTION_RECOGNIZER
> - assert(noAssert && "Invalid LLVM intrinsic name");
> return 0;
> }
>
> @@ -373,4 +370,9 @@
> getType(id, Tys, numTys)));
> }
>
> +// This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method.
> +#define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
> +#include "llvm/Intrinsics.gen"
> +#undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
> +
> // vim: sw=2 ai
>
> Modified: llvm/trunk/lib/VMCore/Module.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Module.cpp (original)
> +++ llvm/trunk/lib/VMCore/Module.cpp Wed Feb 4 13:47:21 2009
> @@ -171,6 +171,25 @@
> return F;
> }
>
> +Constant *Module::getOrInsertTargetIntrinsic(const std::string &Name,
> + const FunctionType *Ty,
> + AttrListPtr
> AttributeList) {
> + ValueSymbolTable &SymTab = getValueSymbolTable();
> +
> + // See if we have a definition for the specified function already.
> + GlobalValue *F =
> dyn_cast_or_null<GlobalValue>(SymTab.lookup(Name));
> + if (F == 0) {
> + // Nope, add it
> + Function *New = Function::Create(Ty,
> GlobalVariable::ExternalLinkage, Name);
> + New->setAttributes(AttributeList);
> + FunctionList.push_back(New);
> + return New; // Return the new prototype.
> + }
> +
> + // Otherwise, we just found the existing function or a prototype.
> + return F;
> +}
> +
> Constant *Module::getOrInsertFunction(const std::string &Name,
> const FunctionType *Ty) {
> AttrListPtr AttributeList = AttrListPtr::get((AttributeWithIndex
> *)0, 0);
>
> Modified: llvm/trunk/lib/VMCore/Verifier.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Verifier.cpp (original)
> +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Feb 4 13:47:21 2009
> @@ -1004,10 +1004,9 @@
> void Verifier::visitCallInst(CallInst &CI) {
> VerifyCallSite(&CI);
>
> - if (Function *F = CI.getCalledFunction()) {
> + if (Function *F = CI.getCalledFunction())
> if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID())
> visitIntrinsicFunctionCall(ID, CI);
> - }
> }
>
> void Verifier::visitInvokeInst(InvokeInst &II) {
>
> Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
> +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Wed Feb 4
> 13:47:21 2009
> @@ -1303,7 +1303,8 @@
>
> // FIXME: REMOVE OSTREAM ARGUMENT
> CodeGenDAGPatterns::CodeGenDAGPatterns(RecordKeeper &R) : Records(R) {
> - Intrinsics = LoadIntrinsics(Records);
> + Intrinsics = LoadIntrinsics(Records, false);
> + TgtIntrinsics = LoadIntrinsics(Records, true);
> ParseNodeInfo();
> ParseNodeTransforms();
> ParseComplexPatterns();
>
> Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original)
> +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Wed Feb 4
> 13:47:21 2009
> @@ -465,6 +465,7 @@
> RecordKeeper &Records;
> CodeGenTarget Target;
> std::vector<CodeGenIntrinsic> Intrinsics;
> + std::vector<CodeGenIntrinsic> TgtIntrinsics;
>
> std::map<Record*, SDNodeInfo> SDNodes;
> std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms;
> @@ -515,18 +516,25 @@
> const CodeGenIntrinsic &getIntrinsic(Record *R) const {
> for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)
> if (Intrinsics[i].TheDef == R) return Intrinsics[i];
> + for (unsigned i = 0, e = TgtIntrinsics.size(); i != e; ++i)
> + if (TgtIntrinsics[i].TheDef == R) return TgtIntrinsics[i];
> assert(0 && "Unknown intrinsic!");
> abort();
> }
>
> const CodeGenIntrinsic &getIntrinsicInfo(unsigned IID) const {
> - assert(IID-1 < Intrinsics.size() && "Bad intrinsic ID!");
> - return Intrinsics[IID-1];
> + if (IID-1 < Intrinsics.size())
> + return Intrinsics[IID-1];
> + if (IID-Intrinsics.size()-1 < TgtIntrinsics.size())
> + return TgtIntrinsics[IID-Intrinsics.size()-1];
> + assert(0 && "Bad intrinsic ID!");
> }
>
> unsigned getIntrinsicID(Record *R) const {
> for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)
> if (Intrinsics[i].TheDef == R) return i;
> + for (unsigned i = 0, e = TgtIntrinsics.size(); i != e; ++i)
> + if (TgtIntrinsics[i].TheDef == R) return i + Intrinsics.size();
> assert(0 && "Unknown intrinsic!");
> abort();
> }
>
> Modified: llvm/trunk/utils/TableGen/CodeGenIntrinsics.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenIntrinsics.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/CodeGenIntrinsics.h (original)
> +++ llvm/trunk/utils/TableGen/CodeGenIntrinsics.h Wed Feb 4
> 13:47:21 2009
> @@ -80,7 +80,8 @@
>
> /// LoadIntrinsics - Read all of the intrinsics defined in the
> specified
> /// .td file.
> - std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper
> &RC);
> + std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper
> &RC,
> + bool TargetOnly);
> }
>
> #endif
>
> Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original)
> +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Wed Feb 4 13:47:21
> 2009
> @@ -426,13 +426,17 @@
> // CodeGenIntrinsic Implementation
> //
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
>
> -std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const
> RecordKeeper &RC) {
> +std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const
> RecordKeeper &RC,
> + bool TargetOnly) {
> std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic");
>
> std::vector<CodeGenIntrinsic> Result;
>
> - for (unsigned i = 0, e = I.size(); i != e; ++i)
> - Result.push_back(CodeGenIntrinsic(I[i]));
> + for (unsigned i = 0, e = I.size(); i != e; ++i) {
> + bool isTarget = I[i]->getValueAsBit("isTarget");
> + if (isTarget == TargetOnly)
> + Result.push_back(CodeGenIntrinsic(I[i]));
> + }
> return Result;
> }
>
>
> Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Wed Feb 4
> 13:47:21 2009
> @@ -25,7 +25,10 @@
> void IntrinsicEmitter::run(std::ostream &OS) {
> EmitSourceFileHeader("Intrinsic Function Source Fragment", OS);
>
> - std::vector<CodeGenIntrinsic> Ints = LoadIntrinsics(Records);
> + std::vector<CodeGenIntrinsic> Ints = LoadIntrinsics(Records,
> TargetOnly);
> +
> + if (TargetOnly && !Ints.empty())
> + TargetPrefix = Ints[0].TargetPrefix;
>
> // Emit the enum information.
> EmitEnumInfo(Ints, OS);
> @@ -91,12 +94,12 @@
> if (Ints[I->second].isOverloaded)
> OS << " if (Len > " << I->first.size()
> << " && !memcmp(Name, \"" << I->first << ".\", "
> - << (I->first.size() + 1) << ")) return Intrinsic::"
> + << (I->first.size() + 1) << ")) return " << TargetPrefix <<
> "Intrinsic::"
> << Ints[I->second].EnumName << ";\n";
> else
> OS << " if (Len == " << I->first.size()
> << " && !memcmp(Name, \"" << I->first << "\", "
> - << I->first.size() << ")) return Intrinsic::"
> + << I->first.size() << ")) return " << TargetPrefix <<
> "Intrinsic::"
> << Ints[I->second].EnumName << ";\n";
> }
> OS << " }\n";
> @@ -351,11 +354,13 @@
> Ints[i].IS.ParamTypeDefs)].push_back(i);
>
> // Loop through the array, emitting one generator for each batch.
> + std::string IntrinsicStr = TargetPrefix + "Intrinsic::";
> +
> for (MapTy::iterator I = UniqueArgInfos.begin(),
> E = UniqueArgInfos.end(); I != E; ++I) {
> for (unsigned i = 0, e = I->second.size(); i != e; ++i)
> - OS << " case Intrinsic::" << Ints[I->second[i]].EnumName <<
> ":\t\t// "
> - << Ints[I->second[i]].Name << "\n";
> + OS << " case " << IntrinsicStr << Ints[I->second[i]].EnumName
> + << ":\t\t// " << Ints[I->second[i]].Name << "\n";
>
> const RecPair &ArgTypes = I->first;
> const std::vector<Record*> &RetTys = ArgTypes.first;
> @@ -392,7 +397,11 @@
> EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints,
> std::ostream &OS) {
> OS << "// Add parameter attributes that are not common to all
> intrinsics.\n";
> OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
> - OS << "AttrListPtr Intrinsic::getAttributes(ID id) {";
> + if (TargetOnly)
> + OS << "static AttrListPtr getAttributes(" << TargetPrefix
> + << "Intrinsic::ID id) {";
> + else
> + OS << "AttrListPtr Intrinsic::getAttributes(ID id) {";
> OS << " // No intrinsic can throw exceptions.\n";
> OS << " Attributes Attr = Attribute::NoUnwind;\n";
> OS << " switch (id) {\n";
> @@ -404,7 +413,8 @@
> switch (Ints[i].ModRef) {
> default: break;
> case CodeGenIntrinsic::NoMem:
> - OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
> + OS << " case " << TargetPrefix << "Intrinsic::" <<
> Ints[i].EnumName
> + << ":\n";
> break;
> }
> }
> @@ -415,7 +425,8 @@
> default: break;
> case CodeGenIntrinsic::ReadArgMem:
> case CodeGenIntrinsic::ReadMem:
> - OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
> + OS << " case " << TargetPrefix << "Intrinsic::" <<
> Ints[i].EnumName
> + << ":\n";
> break;
> }
> }
> @@ -431,7 +442,8 @@
> for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
> if (Ints[i].ArgumentAttributes.empty()) continue;
>
> - OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
> + OS << " case " << TargetPrefix << "Intrinsic::" <<
> Ints[i].EnumName
> + << ":\n";
>
> std::vector<std::pair<unsigned, CodeGenIntrinsic::ArgAttribute>
> > ArgAttrs =
> Ints[i].ArgumentAttributes;
> @@ -495,7 +507,7 @@
> typedef std::map<std::string, std::string>::const_iterator
> StrMapIterator;
> static void EmitBuiltinComparisons(StrMapIterator Start,
> StrMapIterator End,
> unsigned CharStart, unsigned
> Indent,
> - std::ostream &OS) {
> + std::string TargetPrefix,
> std::ostream &OS) {
> if (Start == End) return; // empty range.
>
> // Determine what, if anything, is the same about all these strings.
> @@ -522,7 +534,8 @@
> OS << CommonString.size() - CharStart << "))\n";
> ++Indent;
> }
> - OS << std::string(Indent*2, ' ') << "IntrinsicID = Intrinsic::";
> + OS << std::string(Indent*2, ' ') << "IntrinsicID = " <<
> TargetPrefix
> + << "Intrinsic::";
> OS << Start->second << ";\n";
> return;
> }
> @@ -535,7 +548,8 @@
> OS << ", \"" << (CommonString.c_str()+CharStart) << "\", ";
> OS << CommonString.size()-CharStart << ")) {\n";
>
> - EmitBuiltinComparisons(Start, End, CommonString.size(), Indent
> +1, OS);
> + EmitBuiltinComparisons(Start, End, CommonString.size(), Indent+1,
> + TargetPrefix, OS);
> OS << std::string(Indent*2, ' ') << "}\n";
> return;
> }
> @@ -556,7 +570,7 @@
> for (++NextChar; NextChar != End && NextChar->first[CharStart]
> == ThisChar;
> ++NextChar)
> /*empty*/;
> - EmitBuiltinComparisons(I, NextChar, CharStart+1, Indent+1, OS);
> + EmitBuiltinComparisons(I, NextChar, CharStart+1, Indent+1,
> TargetPrefix,OS);
> OS << std::string(Indent*2, ' ') << " break;\n";
> I = NextChar;
> }
> @@ -566,6 +580,7 @@
> /// EmitTargetBuiltins - All of the builtins in the specified map
> are for the
> /// same target, and we already checked it.
> static void EmitTargetBuiltins(const std::map<std::string,
> std::string> &BIM,
> + const std::string &TargetPrefix,
> std::ostream &OS) {
> // Rearrange the builtins by length.
> std::vector<std::map<std::string, std::string> > BuiltinsByLen;
> @@ -584,7 +599,7 @@
> if (BuiltinsByLen[i].empty()) continue;
> OS << " case " << i << ":\n";
> EmitBuiltinComparisons(BuiltinsByLen[i].begin(),
> BuiltinsByLen[i].end(),
> - 0, 3, OS);
> + 0, 3, TargetPrefix, OS);
> OS << " break;\n";
> }
> OS << " }\n";
> @@ -613,7 +628,22 @@
> OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is
> passed\n";
> OS << "// in as TargetPrefix. The result is assigned to
> 'IntrinsicID'.\n";
> OS << "#ifdef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN\n";
> - OS << " IntrinsicID = Intrinsic::not_intrinsic;\n";
> +
> + if (TargetOnly) {
> + OS << "static " << TargetPrefix << "Intrinsic::ID "
> + << "getIntrinsicForGCCBuiltin(const char "
> + << "*TargetPrefix, const char *BuiltinName) {\n";
> + OS << " " << TargetPrefix << "Intrinsic::ID IntrinsicID = ";
> + } else {
> + OS << "Intrinsic::ID Intrinsic::getIntrinsicForGCCBuiltin(const
> char "
> + << "*TargetPrefix, const char *BuiltinName) {\n";
> + OS << " Intrinsic::ID IntrinsicID = ";
> + }
> +
> + if (TargetOnly)
> + OS << "(" << TargetPrefix<< "Intrinsic::ID)";
> +
> + OS << "Intrinsic::not_intrinsic;\n";
>
> // Note: this could emit significantly better code if we cared.
> for (BIMTy::iterator I = BuiltinMap.begin(), E =
> BuiltinMap.end();I != E;++I){
> @@ -625,8 +655,10 @@
> OS << "{\n";
>
> // Emit the comparisons for this target prefix.
> - EmitTargetBuiltins(I->second, OS);
> + EmitTargetBuiltins(I->second, TargetPrefix, OS);
> OS << " }\n";
> }
> + OS << " return IntrinsicID;\n";
> + OS << "}\n";
> OS << "#endif\n\n";
> }
>
> Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.h?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/IntrinsicEmitter.h (original)
> +++ llvm/trunk/utils/TableGen/IntrinsicEmitter.h Wed Feb 4 13:47:21
> 2009
> @@ -20,9 +20,12 @@
> namespace llvm {
> class IntrinsicEmitter : public TableGenBackend {
> RecordKeeper &Records;
> + bool TargetOnly;
> + std::string TargetPrefix;
>
> public:
> - IntrinsicEmitter(RecordKeeper &R) : Records(R) {}
> + IntrinsicEmitter(RecordKeeper &R, bool T = false)
> + : Records(R), TargetOnly(T) {}
>
> void run(std::ostream &OS);
>
>
> Modified: llvm/trunk/utils/TableGen/TableGen.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=63765&r1=63764&r2=63765&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/utils/TableGen/TableGen.cpp (original)
> +++ llvm/trunk/utils/TableGen/TableGen.cpp Wed Feb 4 13:47:21 2009
> @@ -49,6 +49,7 @@
> GenFastISel,
> GenSubtarget,
> GenIntrinsic,
> + GenTgtIntrinsic,
> GenLLVMCConf,
> PrintEnums
> };
> @@ -82,6 +83,8 @@
> "Generate subtarget enumerations"),
> clEnumValN(GenIntrinsic, "gen-intrinsic",
> "Generate intrinsic information"),
> + clEnumValN(GenTgtIntrinsic, "gen-tgt-intrinsic",
> + "Generate target intrinsic
> information"),
> clEnumValN(GenLLVMCConf, "gen-llvmc",
> "Generate LLVMC configuration
> library"),
> clEnumValN(PrintEnums, "print-enums",
> @@ -190,6 +193,9 @@
> case GenIntrinsic:
> IntrinsicEmitter(Records).run(*Out);
> break;
> + case GenTgtIntrinsic:
> + IntrinsicEmitter(Records, true).run(*Out);
> + break;
> case GenLLVMCConf:
> LLVMCConfigurationEmitter(Records).run(*Out);
> break;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list