Changes in directory llvm/include/llvm/Target:
SubtargetFeature.h updated: 1.3 -> 1.3.2.1 TargetInstrInfo.h updated: 1.80 -> 1.80.2.1 TargetInstrItineraries.h added (r1.6.2.2) TargetLowering.h updated: 1.24 -> 1.24.2.1 TargetMachine.h updated: 1.57 -> 1.57.2.1 --- Log message: Merged mainline into Vector LLVM branch --- Diffs of the changes: (+165 -81) SubtargetFeature.h | 109 ++++++++++++++--------------------------------- TargetInstrInfo.h | 1 TargetInstrItineraries.h | 84 ++++++++++++++++++++++++++++++++++++ TargetLowering.h | 37 +++++++++++++++ TargetMachine.h | 15 +++++- 5 files changed, 165 insertions(+), 81 deletions(-) Index: llvm/include/llvm/Target/SubtargetFeature.h diff -u llvm/include/llvm/Target/SubtargetFeature.h:1.3 llvm/include/llvm/Target/SubtargetFeature.h:1.3.2.1 --- llvm/include/llvm/Target/SubtargetFeature.h:1.3 Fri Sep 2 14:27:43 2005 +++ llvm/include/llvm/Target/SubtargetFeature.h Wed Nov 16 12:31:58 2005 @@ -18,11 +18,9 @@ #ifndef LLVM_TARGET_SUBTARGETFEATURE_H #define LLVM_TARGET_SUBTARGETFEATURE_H - #include <string> #include <vector> -#include <iostream> -#include <cassert> +#include <iosfwd> #include "llvm/Support/DataTypes.h" namespace llvm { @@ -45,6 +43,21 @@ //===----------------------------------------------------------------------===// /// +/// SubtargetInfoKV - Used to provide key value pairs for CPU and arbitrary +/// pointers. +// +struct SubtargetInfoKV { + const char *Key; // K-V key string + void *Value; // K-V pointer value + + // Compare routine for std binary search + bool operator<(const std::string &S) const { + return strcmp(Key, S.c_str()) < 0; + } +}; + +//===----------------------------------------------------------------------===// +/// /// SubtargetFeatures - Manages the enabling and disabling of subtarget /// specific features. Features are encoded as a string of the form /// "cpu,+attr1,+attr2,-attr3,...,+attrN" @@ -57,87 +70,31 @@ /// class SubtargetFeatures { -private: std::vector<std::string> Features; // Subtarget features as a vector - - // Determine if a feature has a flag; '+' or '-' - static inline bool hasFlag(const std::string &Feature) { - assert(!Feature.empty() && "Empty string"); - // Get first character - char Ch = Feature[0]; - // Check if first character is '+' or '-' flag - return Ch == '+' || Ch =='-'; - } - - // Return true if enable flag; '+'. - static inline bool isEnabled(const std::string &Feature) { - assert(!Feature.empty() && "Empty string"); - // Get first character - char Ch = Feature[0]; - // Check if first character is '+' for enabled - return Ch == '+'; - } - - // Return a string with a prepended flag; '+' or '-'. - static inline std::string PrependFlag(const std::string &Feature, - bool IsEnabled) { - assert(!Feature.empty() && "Empty string"); - if (hasFlag(Feature)) return Feature; - return std::string(IsEnabled ? "+" : "-") + Feature; - } - - // Return string stripped of flag. - static inline std::string StripFlag(const std::string &Feature) { - return hasFlag(Feature) ? Feature.substr(1) : Feature; - } - - /// Splits a string of comma separated items in to a vector of strings. - static void Split(std::vector<std::string> &V, const std::string &S); - - /// Join a vector of strings into a string with a comma separating each - /// item. - static std::string Join(const std::vector<std::string> &V); - - /// Convert a string to lowercase. - static std::string toLower(const std::string &S); - - /// Find item in array using binary search. - static const SubtargetFeatureKV *Find(const std::string &S, - const SubtargetFeatureKV *A, size_t L); - public: - /// Ctor. - SubtargetFeatures(const std::string Initial = std::string()) { - // Break up string into separate features - Split(Features, Initial); - } + SubtargetFeatures(const std::string &Initial = std::string()); /// Features string accessors. - inline std::string getString() const { return Join(Features); } - void setString(const std::string &Initial) { - // Throw out old features - Features.clear(); - // Break up string into separate features - Split(Features, toLower(Initial)); - } + std::string getString() const; + void setString(const std::string &Initial); - /// Setting CPU string. Replaces previous setting. Setting to "" clears CPU. - void setCPU(std::string String) { Features[0] = toLower(String); } + /// Set the CPU string. Replaces previous setting. Setting to "" clears CPU. + void setCPU(const std::string &String); + + /// Setting CPU string only if no string is set. + void setCPUIfNone(const std::string &String); /// Adding Features. void AddFeature(const std::string &String, bool IsEnabled = true); - - /// Display help for feature choices. - static void Help(const char *Heading, - const SubtargetFeatureKV *Table, size_t TableSize); - - /// Parse feature string for quick usage. - static uint32_t Parse(const std::string &String, - const std::string &DefaultCPU, - const SubtargetFeatureKV *CPUTable, - size_t CPUTableSize, - const SubtargetFeatureKV *FeatureTable, - size_t FeatureTableSize); + + /// Get feature bits. + uint32_t getBits(const SubtargetFeatureKV *CPUTable, + size_t CPUTableSize, + const SubtargetFeatureKV *FeatureTable, + size_t FeatureTableSize); + + /// Get info pointer + void *getInfo(const SubtargetInfoKV *Table, size_t TableSize); /// Print feature string. void print(std::ostream &OS) const; Index: llvm/include/llvm/Target/TargetInstrInfo.h diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.80 llvm/include/llvm/Target/TargetInstrInfo.h:1.80.2.1 --- llvm/include/llvm/Target/TargetInstrInfo.h:1.80 Fri Sep 2 13:16:20 2005 +++ llvm/include/llvm/Target/TargetInstrInfo.h Wed Nov 16 12:31:58 2005 @@ -146,7 +146,6 @@ return get(Opcode).numOperands; } - InstrSchedClass getSchedClass(MachineOpCode Opcode) const { return get(Opcode).schedClass; } Index: llvm/include/llvm/Target/TargetInstrItineraries.h diff -c /dev/null llvm/include/llvm/Target/TargetInstrItineraries.h:1.6.2.2 *** /dev/null Wed Nov 16 12:32:09 2005 --- llvm/include/llvm/Target/TargetInstrItineraries.h Wed Nov 16 12:31:58 2005 *************** *** 0 **** --- 1,84 ---- + //===-- llvm/Target/TargetInstrItineraries.h - Scheduling -------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the James M. Laskey and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file describes the structures used for instruction itineraries and + // states. This is used by schedulers to determine instruction states and + // latencies. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H + #define LLVM_TARGET_TARGETINSTRITINERARIES_H + + namespace llvm { + + //===----------------------------------------------------------------------===// + // Instruction stage - These values represent a step in the execution of an + // instruction. The latency represents the number of discrete time slots used + // need to complete the stage. Units represent the choice of functional units + // that can be used to complete the stage. Eg. IntUnit1, IntUnit2. + // + struct InstrStage { + unsigned Cycles; // Length of stage in machine cycles + unsigned Units; // Choice of functional units + }; + + + //===----------------------------------------------------------------------===// + // Instruction itinerary - An itinerary represents a sequential series of steps + // required to complete an instruction. Itineraries are represented as + // sequences of instruction stages. + // + struct InstrItinerary { + unsigned First; // Index of first stage in itinerary + unsigned Last; // Index of last + 1 stage in itinerary + }; + + + + //===----------------------------------------------------------------------===// + // Instruction itinerary Data - Itinerary data supplied by a subtarget to be + // used by a target. + // + struct InstrItineraryData { + InstrStage *Stages; // Array of stages selected + InstrItinerary *Itineratries; // Array of itineraries selected + + // + // Ctors. + // + InstrItineraryData() : Stages(0), Itineratries(0) {} + InstrItineraryData(InstrStage *S, InstrItinerary *I) : Stages(S), Itineratries(I) {} + + // + // isEmpty - Returns true if there are no itineraries. + // + inline bool isEmpty() const { return Itineratries == 0; } + + // + // begin - Return the first stage of the itinerary. + // + inline InstrStage *begin(unsigned ItinClassIndx) const { + unsigned StageIdx = Itineratries[ItinClassIndx].First; + return Stages + StageIdx; + } + + // + // end - Return the last+1 stage of the itinerary. + // + inline InstrStage *end(unsigned ItinClassIndx) const { + unsigned StageIdx = Itineratries[ItinClassIndx].Last; + return Stages + StageIdx; + } + }; + + + } // End llvm namespace + + #endif Index: llvm/include/llvm/Target/TargetLowering.h diff -u llvm/include/llvm/Target/TargetLowering.h:1.24 llvm/include/llvm/Target/TargetLowering.h:1.24.2.1 --- llvm/include/llvm/Target/TargetLowering.h:1.24 Tue Sep 27 17:13:36 2005 +++ llvm/include/llvm/Target/TargetLowering.h Wed Nov 16 12:31:58 2005 @@ -83,7 +83,15 @@ /// isSetCCExpensive - Return true if the setcc operation is expensive for /// this target. bool isSetCCExpensive() const { return SetCCIsExpensive; } - + + /// isIntDivCheap() - Return true if integer divide is usually cheaper than + /// a sequence of several shifts, adds, and multiplies for this target. + bool isIntDivCheap() const { return IntDivIsCheap; } + + /// isPow2DivCheap() - Return true if pow2 div is cheaper than a chain of + /// srl/add/sra. + bool isPow2DivCheap() const { return Pow2DivIsCheap; } + /// getSetCCResultTy - Return the ValueType of the result of setcc operations. /// MVT::ValueType getSetCCResultTy() const { return SetCCResultTy; } @@ -262,6 +270,16 @@ /// setcc operations into other operations if possible. void setSetCCIsExpensive() { SetCCIsExpensive = true; } + /// setIntDivIsCheap - Tells the code generator that integer divide is + /// expensive, and if possible, should be replaced by an alternate sequence + /// of instructions not containing an integer divide. + void setIntDivIsCheap(bool isCheap = true) { IntDivIsCheap = isCheap; } + + /// setPow2DivIsCheap - Tells the code generator that it shouldn't generate + /// srl/add/sra for a signed divide by power of two, and let the target handle + /// it. + void setPow2DivIsCheap(bool isCheap = true) { Pow2DivIsCheap = isCheap; } + /// addRegisterClass - Add the specified register class as an available /// regclass for the specified value type. This indicates the selector can /// handle values of that class natively. @@ -311,6 +329,12 @@ unsigned CallingConv, bool isTailCall, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) = 0; + /// LowerReturnTo - This hook lowers a return instruction into the appropriate + /// legal ISD::RET node for the target's current ABI. This method is optional + /// and is intended for targets that need non-standard behavior. + virtual SDOperand LowerReturnTo(SDOperand Chain, SDOperand Op, + SelectionDAG &DAG); + /// LowerVAStart - This lowers the llvm.va_start intrinsic. If not /// implemented, this method prints a message and aborts. This method should /// return the modified chain value. Note that VAListPtr* correspond to the @@ -385,6 +409,17 @@ /// setcc operations into other operations if possible. bool SetCCIsExpensive; + /// IntDivIsCheap - Tells the code generator not to expand integer divides by + /// constants into a sequence of muls, adds, and shifts. This is a hack until + /// a real cost model is in place. If we ever optimize for size, this will be + /// set to true unconditionally. + bool IntDivIsCheap; + + /// Pow2DivIsCheap - Tells the code generator that it shouldn't generate + /// srl/add/sra for a signed divide by power of two, and let the target handle + /// it. + bool Pow2DivIsCheap; + /// SetCCResultTy - The type that SetCC operations use. This defaults to the /// PointerTy. MVT::ValueType SetCCResultTy; Index: llvm/include/llvm/Target/TargetMachine.h diff -u llvm/include/llvm/Target/TargetMachine.h:1.57 llvm/include/llvm/Target/TargetMachine.h:1.57.2.1 --- llvm/include/llvm/Target/TargetMachine.h:1.57 Fri Aug 5 16:53:21 2005 +++ llvm/include/llvm/Target/TargetMachine.h Wed Nov 16 12:31:58 2005 @@ -15,6 +15,7 @@ #define LLVM_TARGET_TARGETMACHINE_H #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetInstrItineraries.h" #include <cassert> namespace llvm { @@ -122,6 +123,13 @@ /// otherwise return null. /// virtual TargetJITInfo *getJITInfo() { return 0; } + + /// getInstrItineraryData - Returns instruction itinerary data for the target + /// or specific subtarget. + /// + virtual const InstrItineraryData getInstrItineraryData() const { + return InstrItineraryData(); + } // These are deprecated interfaces. virtual const TargetSchedInfo *getSchedInfo() const { return 0; } @@ -135,11 +143,12 @@ /// addPassesToEmitFile - Add passes to the specified pass manager to get /// the specified file emitted. Typically this will involve several steps of - /// code generation. This method should return true if emission of this file - /// type is not supported. + /// code generation. If Fast is set to true, the code generator should emit + /// code as fast as possible, without regard for compile time. This method + /// should return true if emission of this file type is not supported. /// virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out, - CodeGenFileType FileType) { + CodeGenFileType FileType, bool Fast) { return true; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits