Skip to content

Commit

Permalink
Fix 80-col and early exit in cost model
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172877 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rengolin committed Jan 19, 2013
1 parent d32eea9 commit 065db23
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/Analysis/TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,38 +289,42 @@ ImmutablePass *llvm::createNoTargetTransformInfoPass() {

//======================================= COST TABLES ==

CostTable::CostTable(const CostTableEntry *table, const size_t size, unsigned numTypes)
CostTable::CostTable(const CostTableEntry *table,
const size_t size,
unsigned numTypes)
: table(table), size(size), numTypes(numTypes) {
assert(table && "missing cost table");
assert(size > 0 && "empty cost table");
}

unsigned CostTable::_findCost(int ISD, MVT *Types) const {
for (unsigned i = 0; i < size; ++i) {
if (table[i].ISD == ISD) {
bool found = true;
for (unsigned t=0; t<numTypes; t++) {
if (table[i].Types[t] != Types[t]) {
found = false;
break;
}
if (table[i].ISD != ISD)
continue;
bool found = true;
for (unsigned t=0; t<numTypes; t++) {
if (table[i].Types[t] != Types[t]) {
found = false;
break;
}
if (found)
return table[i].Cost;
}
if (found)
return table[i].Cost;
}
return COST_NOT_FOUND;
}

UnaryCostTable::UnaryCostTable(const CostTableEntry *table, const size_t size)
UnaryCostTable::UnaryCostTable(const CostTableEntry *table,
const size_t size)
: CostTable(table, size, 1) { }

unsigned UnaryCostTable::findCost(int ISD, MVT Type) const {
MVT tys[1] = { Type };
return _findCost(ISD, tys);
}

BinaryCostTable::BinaryCostTable(const CostTableEntry *table, const size_t size)
BinaryCostTable::BinaryCostTable(const CostTableEntry *table,
const size_t size)
: CostTable(table, size, 2) { }

unsigned BinaryCostTable::findCost(int ISD, MVT Type, MVT SrcType) const {
Expand Down

0 comments on commit 065db23

Please sign in to comment.