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
This commit is contained in:
John Thompson
2010-09-13 18:15:37 +00:00
parent c32a2260a6
commit eac6e1d0c7
9 changed files with 419 additions and 103 deletions

View File

@@ -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

View File

@@ -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