mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
For PR1064:
Implement the arbitrary bit-width integer feature. The feature allows integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 16, 32, and 64 bit integers. This change does several things: 1. Introduces a new Derived Type, IntegerType, to represent the number of bits in an integer. The Type classes SubclassData field is used to store the number of bits. This allows 2^23 bits in an integer type. 2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and 64-bit integers. These are replaced with just IntegerType which is not a primitive any more. 3. Adjust the rest of LLVM to account for this change. Note that while this incremental change lays the foundation for arbitrary bit-width integers, LLVM has not yet been converted to actually deal with them in any significant way. Most optimization passes, for example, will still only deal with the byte-width integer types. Future increments will rectify this situation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33113 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
using namespace llvm;
|
||||
|
||||
@@ -528,18 +529,27 @@ void IndVarSimplify::runOnLoop(Loop *L) {
|
||||
// induction variable to the right size for them, avoiding the need for the
|
||||
// code evaluation methods to insert induction variables of different sizes.
|
||||
if (DifferingSizes) {
|
||||
bool InsertedSizes[17] = { false };
|
||||
InsertedSizes[LargestType->getPrimitiveSize()] = true;
|
||||
for (unsigned i = 0, e = IndVars.size(); i != e; ++i)
|
||||
if (!InsertedSizes[IndVars[i].first->getType()->getPrimitiveSize()]) {
|
||||
SmallVector<unsigned,4> InsertedSizes;
|
||||
InsertedSizes.push_back(LargestType->getPrimitiveSizeInBits());
|
||||
for (unsigned i = 0, e = IndVars.size(); i != e; ++i) {
|
||||
unsigned ithSize = IndVars[i].first->getType()->getPrimitiveSizeInBits();
|
||||
bool alreadyInsertedSize = false;
|
||||
for (SmallVector<unsigned,4>::iterator I = InsertedSizes.begin(),
|
||||
E = InsertedSizes.end(); I != E; ++I)
|
||||
if (*I == ithSize) {
|
||||
alreadyInsertedSize = true;
|
||||
break;
|
||||
}
|
||||
if (!alreadyInsertedSize) {
|
||||
PHINode *PN = IndVars[i].first;
|
||||
InsertedSizes[PN->getType()->getPrimitiveSize()] = true;
|
||||
InsertedSizes.push_back(ithSize);
|
||||
Instruction *New = new TruncInst(IndVar, PN->getType(), "indvar",
|
||||
InsertPt);
|
||||
Rewriter.addInsertedValue(New, SE->getSCEV(New));
|
||||
DOUT << "INDVARS: Made trunc IV for " << *PN
|
||||
<< " NewVal = " << *New << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite all induction variables in terms of the canonical induction
|
||||
|
Reference in New Issue
Block a user