Skip to content

Commit

Permalink
Merging r114490: "Fixed pr20314-2.c failure, added E, F, p constraint…
Browse files Browse the repository at this point in the history
… letters."

git-crossrepo-prefix: llvm/
git-crossrepo-prefix: clang/
  • Loading branch information
LLVM Monorepo conversion committed Sep 21, 2010
3 parents 2cee3e1 + 67aff16 + 7ccc58f commit 6258012
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Basic/TargetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
Info.setAllowsRegister();
Info.setAllowsMemory();
break;
case 'E': // immediate floating point.
case 'F': // immediate floating point.
case 'p': // address operand.
break;
case ',': // multiple alternative constraint. Ignore comma.
break;
case '?': // Disparage slightly code.
Expand Down
23 changes: 17 additions & 6 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2496,7 +2496,10 @@ TargetLowering::getConstraintType(const std::string &Constraint) const {
return C_Memory;
case 'i': // Simple Integer or Relocatable Constant
case 'n': // Simple Integer
case 'E': // Floating Point Constant
case 'F': // Floating Point Constant
case 's': // Relocatable Constant
case 'p': // Address.
case 'X': // Allow ANY value.
case 'I': // Target registers.
case 'J':
Expand All @@ -2506,6 +2509,8 @@ TargetLowering::getConstraintType(const std::string &Constraint) const {
case 'N':
case 'O':
case 'P':
case '<':
case '>':
return C_Other;
}
}
Expand Down Expand Up @@ -2664,6 +2669,7 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
/// ConstraintOperands - Information about all of the constraints.
std::vector<AsmOperandInfo> ConstraintOperands;
const InlineAsm *IA = cast<InlineAsm>(CS.getCalledValue());
unsigned maCount = 0; // Largest number of multiple alternative constraints.

// Do a prepass over the constraints, canonicalizing them, and building up the
// ConstraintOperands list.
Expand All @@ -2677,6 +2683,10 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
ConstraintOperands.push_back(AsmOperandInfo(ConstraintInfos[i]));
AsmOperandInfo &OpInfo = ConstraintOperands.back();

// Update multiple alternative constraint count.
if (OpInfo.multipleAlternatives.size() > maCount)
maCount = OpInfo.multipleAlternatives.size();

EVT OpVT = MVT::Other;

// Compute the value type for each operand.
Expand Down Expand Up @@ -2711,7 +2721,6 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(

// If we have multiple alternative constraints, select the best alternative.
if (ConstraintInfos.size()) {
unsigned maCount = ConstraintInfos[0].multipleAlternatives.size();
if (maCount) {
unsigned bestMAIndex = 0;
int bestWeight = -1;
Expand All @@ -2727,8 +2736,6 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
AsmOperandInfo& OpInfo = ConstraintOperands[cIndex];
if (OpInfo.Type == InlineAsm::isClobber)
continue;
assert((OpInfo.multipleAlternatives.size() == maCount)
&& "Constraint has inconsistent multiple alternative count.");

// If this is an output operand with a matching input operand, look up the
// matching input. If their types mismatch, e.g. one is an integer, the
Expand Down Expand Up @@ -2827,12 +2834,16 @@ static unsigned getConstraintGenerality(TargetLowering::ConstraintType CT) {
/// and the current alternative constraint selected.
int TargetLowering::getMultipleConstraintMatchWeight(
AsmOperandInfo &info, int maIndex) const {
std::vector<std::string> &rCodes = info.multipleAlternatives[maIndex].Codes;
std::vector<std::string> *rCodes;
if (maIndex >= (int)info.multipleAlternatives.size())
rCodes = &info.Codes;
else
rCodes = &info.multipleAlternatives[maIndex].Codes;
int BestWeight = -1;

// Loop over the options, keeping track of the most general one.
for (unsigned i = 0, e = rCodes.size(); i != e; ++i) {
int weight = getSingleConstraintMatchWeight(info, rCodes[i].c_str());
for (unsigned i = 0, e = rCodes->size(); i != e; ++i) {
int weight = getSingleConstraintMatchWeight(info, (*rCodes)[i].c_str());
if (weight > BestWeight)
BestWeight = weight;
}
Expand Down

0 comments on commit 6258012

Please sign in to comment.