diff options
author | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2010-09-13 18:15:37 +0000 |
---|---|---|
committer | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2010-09-13 18:15:37 +0000 |
commit | eac6e1d0c748afc3d1496be0753ffbe5f5a4279b (patch) | |
tree | 94079e066b7fbaf541433ad07e9453331d09b7ba /include | |
parent | c32a2260a6145000581a74fd61ba57bdcc4cb951 (diff) | |
download | external_llvm-eac6e1d0c748afc3d1496be0753ffbe5f5a4279b.zip external_llvm-eac6e1d0c748afc3d1496be0753ffbe5f5a4279b.tar.gz external_llvm-eac6e1d0c748afc3d1496be0753ffbe5f5a4279b.tar.bz2 |
Added skeleton for inline asm multiple alternative constraint support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/InlineAsm.h | 33 | ||||
-rw-r--r-- | include/llvm/Target/TargetLowering.h | 31 |
2 files changed, 64 insertions, 0 deletions
diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index 105b1bc..0cb55b7 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -87,6 +87,19 @@ public: isClobber // '~x' }; + struct SubConstraintInfo { + /// MatchingInput - If this is not -1, this is an output constraint where an + /// input constraint is required to match it (e.g. "0"). The value is the + /// constraint number that matches this one (for example, if this is + /// constraint #0 and constraint #4 has the value "0", this will be 4). + signed char MatchingInput; + /// Code - The constraint code, either the register name (in braces) or the + /// constraint letter/number. + std::vector<std::string> Codes; + /// Default constructor. + SubConstraintInfo() : MatchingInput(-1) {} + }; + struct ConstraintInfo { /// Type - The basic type of the constraint: input/output/clobber /// @@ -120,11 +133,31 @@ public: /// constraint letter/number. std::vector<std::string> Codes; + /// isMultipleAlternative - '|': has multiple-alternative constraints. + bool isMultipleAlternative; + + /// multipleAlternatives - If there are multiple alternative constraints, + /// this array will contain them. Otherwise it will be empty. + std::vector<SubConstraintInfo> multipleAlternatives; + + /// The currently selected alternative constraint index. + unsigned currentAlternativeIndex; + + ///Default constructor. + ConstraintInfo(); + + /// Copy constructor. + ConstraintInfo(const ConstraintInfo &other); + /// Parse - Analyze the specified string (e.g. "=*&{eax}") and fill in the /// fields in this structure. If the constraint string is not understood, /// return true, otherwise return false. bool Parse(StringRef Str, std::vector<InlineAsm::ConstraintInfo> &ConstraintsSoFar); + + /// selectAlternative - Point this constraint to the alternative constraint + /// indicated by the index. + void selectAlternative(unsigned index); }; /// ParseConstraints - Split up the constraint string into the specific diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 29de994..73ab11a 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -45,6 +45,7 @@ namespace llvm { class Function; class FastISel; class FunctionLoweringInfo; + class ImmutableCallSite; class MachineBasicBlock; class MachineFunction; class MachineFrameInfo; @@ -1356,12 +1357,42 @@ public: /// returns the output operand it matches. unsigned getMatchedOperand() const; + /// Copy constructor for copying from an AsmOperandInfo. + AsmOperandInfo(const AsmOperandInfo &info) + : InlineAsm::ConstraintInfo(info), + ConstraintCode(info.ConstraintCode), + ConstraintType(info.ConstraintType), + CallOperandVal(info.CallOperandVal), + ConstraintVT(info.ConstraintVT) { + } + + /// Copy constructor for copying from a ConstraintInfo. AsmOperandInfo(const InlineAsm::ConstraintInfo &info) : InlineAsm::ConstraintInfo(info), ConstraintType(TargetLowering::C_Unknown), CallOperandVal(0), ConstraintVT(MVT::Other) { } }; + + /// ParseConstraints - Split up the constraint string from the inline + /// assembly value into the specific constraints and their prefixes, + /// and also tie in the associated operand values. + /// If this returns an empty vector, and if the constraint string itself + /// isn't empty, there was an error parsing. + virtual std::vector<AsmOperandInfo> ParseConstraints( + ImmutableCallSite CS) const; + + /// Examine constraint type and operand type and determine a weight value, + /// where: -1 = invalid match, and 0 = so-so match to 5 = good match. + /// The operand object must already have been set up with the operand type. + virtual int getMultipleConstraintMatchWeight( + AsmOperandInfo &info, int maIndex) const; + + /// Examine constraint string and operand type and determine a weight value, + /// where: -1 = invalid match, and 0 = so-so match to 3 = good match. + /// The operand object must already have been set up with the operand type. + virtual int getSingleConstraintMatchWeight( + AsmOperandInfo &info, const char *constraint) const; /// ComputeConstraintToUse - Determines the constraint code and constraint /// type to use for the specific AsmOperandInfo, setting |