mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
Enable emitting of constant values in non-default address space as well. The APIs emitting constants now take an additional parameter signifying the address space in which to emit. The APIs like getData8BitsDirective() etc are made virtual enabling targets to be able to define appropirate directivers for various sizes and address spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63377 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
826d11463b
commit
c8d7bc850d
@ -309,7 +309,7 @@ namespace llvm {
|
|||||||
protected:
|
protected:
|
||||||
/// EmitZeros - Emit a block of zeros.
|
/// EmitZeros - Emit a block of zeros.
|
||||||
///
|
///
|
||||||
void EmitZeros(uint64_t NumZeros) const;
|
void EmitZeros(uint64_t NumZeros, unsigned AddrSpace = 0) const;
|
||||||
|
|
||||||
/// EmitString - Emit a zero-byte-terminated string constant.
|
/// EmitString - Emit a zero-byte-terminated string constant.
|
||||||
///
|
///
|
||||||
@ -320,7 +320,7 @@ namespace llvm {
|
|||||||
void EmitConstantValueOnly(const Constant *CV);
|
void EmitConstantValueOnly(const Constant *CV);
|
||||||
|
|
||||||
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
||||||
void EmitGlobalConstant(const Constant* CV);
|
void EmitGlobalConstant(const Constant* CV, unsigned AddrSpace = 0);
|
||||||
|
|
||||||
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
|
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// printDataDirective - This method prints the asm directive for the
|
/// printDataDirective - This method prints the asm directive for the
|
||||||
/// specified type.
|
/// specified type.
|
||||||
void printDataDirective(const Type *type);
|
void printDataDirective(const Type *type, unsigned AddrSpace = 0);
|
||||||
|
|
||||||
/// printSuffixedName - This prints a name with preceding
|
/// printSuffixedName - This prints a name with preceding
|
||||||
/// getPrivateGlobalPrefix and the specified suffix, handling quoted names
|
/// getPrivateGlobalPrefix and the specified suffix, handling quoted names
|
||||||
@ -371,11 +371,12 @@ namespace llvm {
|
|||||||
const GlobalValue *findGlobalValue(const Constant* CV);
|
const GlobalValue *findGlobalValue(const Constant* CV);
|
||||||
void EmitLLVMUsedList(Constant *List);
|
void EmitLLVMUsedList(Constant *List);
|
||||||
void EmitXXStructorList(Constant *List);
|
void EmitXXStructorList(Constant *List);
|
||||||
void EmitGlobalConstantStruct(const ConstantStruct* CVS);
|
void EmitGlobalConstantStruct(const ConstantStruct* CVS,
|
||||||
|
unsigned AddrSpace);
|
||||||
void EmitGlobalConstantArray(const ConstantArray* CVA);
|
void EmitGlobalConstantArray(const ConstantArray* CVA);
|
||||||
void EmitGlobalConstantVector(const ConstantVector* CP);
|
void EmitGlobalConstantVector(const ConstantVector* CP);
|
||||||
void EmitGlobalConstantFP(const ConstantFP* CFP);
|
void EmitGlobalConstantFP(const ConstantFP* CFP, unsigned AddrSpace);
|
||||||
void EmitGlobalConstantLargeInt(const ConstantInt* CI);
|
void EmitGlobalConstantLargeInt(const ConstantInt* CI, unsigned AddrSpace);
|
||||||
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
|
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -598,6 +598,21 @@ namespace llvm {
|
|||||||
|
|
||||||
static unsigned getULEB128Size(unsigned Value);
|
static unsigned getULEB128Size(unsigned Value);
|
||||||
|
|
||||||
|
// Data directive accessors
|
||||||
|
//
|
||||||
|
virtual const char *getData8bitsDirective(unsigned AddrSpace = 0) const {
|
||||||
|
return Data8bitsDirective;
|
||||||
|
}
|
||||||
|
virtual const char *getData16bitsDirective(unsigned AddrSpace = 0) const {
|
||||||
|
return Data16bitsDirective;
|
||||||
|
}
|
||||||
|
virtual const char *getData32bitsDirective(unsigned AddrSpace = 0) const {
|
||||||
|
return Data32bitsDirective;
|
||||||
|
}
|
||||||
|
virtual const char *getData64bitsDirective(unsigned AddrSpace = 0) const {
|
||||||
|
return Data64bitsDirective;
|
||||||
|
}
|
||||||
|
|
||||||
// Accessors.
|
// Accessors.
|
||||||
//
|
//
|
||||||
const Section *getTextSection() const {
|
const Section *getTextSection() const {
|
||||||
@ -711,18 +726,6 @@ namespace llvm {
|
|||||||
const char *getAscizDirective() const {
|
const char *getAscizDirective() const {
|
||||||
return AscizDirective;
|
return AscizDirective;
|
||||||
}
|
}
|
||||||
const char *getData8bitsDirective() const {
|
|
||||||
return Data8bitsDirective;
|
|
||||||
}
|
|
||||||
const char *getData16bitsDirective() const {
|
|
||||||
return Data16bitsDirective;
|
|
||||||
}
|
|
||||||
const char *getData32bitsDirective() const {
|
|
||||||
return Data32bitsDirective;
|
|
||||||
}
|
|
||||||
const char *getData64bitsDirective() const {
|
|
||||||
return Data64bitsDirective;
|
|
||||||
}
|
|
||||||
const char *getJumpTableDirective() const {
|
const char *getJumpTableDirective() const {
|
||||||
return JumpTableDirective;
|
return JumpTableDirective;
|
||||||
}
|
}
|
||||||
|
@ -770,7 +770,7 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
|
|||||||
|
|
||||||
/// EmitZeros - Emit a block of zeros.
|
/// EmitZeros - Emit a block of zeros.
|
||||||
///
|
///
|
||||||
void AsmPrinter::EmitZeros(uint64_t NumZeros) const {
|
void AsmPrinter::EmitZeros(uint64_t NumZeros, unsigned AddrSpace) const {
|
||||||
if (NumZeros) {
|
if (NumZeros) {
|
||||||
if (TAI->getZeroDirective()) {
|
if (TAI->getZeroDirective()) {
|
||||||
O << TAI->getZeroDirective() << NumZeros;
|
O << TAI->getZeroDirective() << NumZeros;
|
||||||
@ -779,7 +779,7 @@ void AsmPrinter::EmitZeros(uint64_t NumZeros) const {
|
|||||||
O << '\n';
|
O << '\n';
|
||||||
} else {
|
} else {
|
||||||
for (; NumZeros; --NumZeros)
|
for (; NumZeros; --NumZeros)
|
||||||
O << TAI->getData8bitsDirective() << "0\n";
|
O << TAI->getData8bitsDirective(AddrSpace) << "0\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -956,7 +956,8 @@ void AsmPrinter::EmitGlobalConstantVector(const ConstantVector *CP) {
|
|||||||
EmitGlobalConstant(CP->getOperand(I));
|
EmitGlobalConstant(CP->getOperand(I));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::EmitGlobalConstantStruct(const ConstantStruct *CVS) {
|
void AsmPrinter::EmitGlobalConstantStruct(const ConstantStruct *CVS,
|
||||||
|
unsigned AddrSpace) {
|
||||||
// Print the fields in successive locations. Pad to align if needed!
|
// Print the fields in successive locations. Pad to align if needed!
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
unsigned Size = TD->getTypePaddedSize(CVS->getType());
|
unsigned Size = TD->getTypePaddedSize(CVS->getType());
|
||||||
@ -972,46 +973,47 @@ void AsmPrinter::EmitGlobalConstantStruct(const ConstantStruct *CVS) {
|
|||||||
sizeSoFar += fieldSize + padSize;
|
sizeSoFar += fieldSize + padSize;
|
||||||
|
|
||||||
// Now print the actual field value.
|
// Now print the actual field value.
|
||||||
EmitGlobalConstant(field);
|
EmitGlobalConstant(field, AddrSpace);
|
||||||
|
|
||||||
// Insert padding - this may include padding to increase the size of the
|
// Insert padding - this may include padding to increase the size of the
|
||||||
// current field up to the ABI size (if the struct is not packed) as well
|
// current field up to the ABI size (if the struct is not packed) as well
|
||||||
// as padding to ensure that the next field starts at the right offset.
|
// as padding to ensure that the next field starts at the right offset.
|
||||||
EmitZeros(padSize);
|
EmitZeros(padSize, AddrSpace);
|
||||||
}
|
}
|
||||||
assert(sizeSoFar == cvsLayout->getSizeInBytes() &&
|
assert(sizeSoFar == cvsLayout->getSizeInBytes() &&
|
||||||
"Layout of constant struct may be incorrect!");
|
"Layout of constant struct may be incorrect!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP) {
|
void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
|
||||||
|
unsigned AddrSpace) {
|
||||||
// FP Constants are printed as integer constants to avoid losing
|
// FP Constants are printed as integer constants to avoid losing
|
||||||
// precision...
|
// precision...
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
if (CFP->getType() == Type::DoubleTy) {
|
if (CFP->getType() == Type::DoubleTy) {
|
||||||
double Val = CFP->getValueAPF().convertToDouble(); // for comment only
|
double Val = CFP->getValueAPF().convertToDouble(); // for comment only
|
||||||
uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
|
uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
|
||||||
if (TAI->getData64bitsDirective())
|
if (TAI->getData64bitsDirective(AddrSpace))
|
||||||
O << TAI->getData64bitsDirective() << i << '\t'
|
O << TAI->getData64bitsDirective(AddrSpace) << i << '\t'
|
||||||
<< TAI->getCommentString() << " double value: " << Val << '\n';
|
<< TAI->getCommentString() << " double value: " << Val << '\n';
|
||||||
else if (TD->isBigEndian()) {
|
else if (TD->isBigEndian()) {
|
||||||
O << TAI->getData32bitsDirective() << unsigned(i >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " double most significant word " << Val << '\n';
|
<< " double most significant word " << Val << '\n';
|
||||||
O << TAI->getData32bitsDirective() << unsigned(i)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " double least significant word " << Val << '\n';
|
<< " double least significant word " << Val << '\n';
|
||||||
} else {
|
} else {
|
||||||
O << TAI->getData32bitsDirective() << unsigned(i)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " double least significant word " << Val << '\n';
|
<< " double least significant word " << Val << '\n';
|
||||||
O << TAI->getData32bitsDirective() << unsigned(i >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " double most significant word " << Val << '\n';
|
<< " double most significant word " << Val << '\n';
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (CFP->getType() == Type::FloatTy) {
|
} else if (CFP->getType() == Type::FloatTy) {
|
||||||
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
|
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
|
||||||
O << TAI->getData32bitsDirective()
|
O << TAI->getData32bitsDirective(AddrSpace)
|
||||||
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue()
|
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue()
|
||||||
<< '\t' << TAI->getCommentString() << " float " << Val << '\n';
|
<< '\t' << TAI->getCommentString() << " float " << Val << '\n';
|
||||||
return;
|
return;
|
||||||
@ -1026,42 +1028,42 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP) {
|
|||||||
DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
|
DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
|
||||||
&ignored);
|
&ignored);
|
||||||
if (TD->isBigEndian()) {
|
if (TD->isBigEndian()) {
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48)
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double most significant halfword of ~"
|
<< " long double most significant halfword of ~"
|
||||||
<< DoubleVal.convertToDouble() << '\n';
|
<< DoubleVal.convertToDouble() << '\n';
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32)
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next halfword\n";
|
<< " long double next halfword\n";
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 16)
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next halfword\n";
|
<< " long double next halfword\n";
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0])
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next halfword\n";
|
<< " long double next halfword\n";
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[1])
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double least significant halfword\n";
|
<< " long double least significant halfword\n";
|
||||||
} else {
|
} else {
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[1])
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double least significant halfword of ~"
|
<< " long double least significant halfword of ~"
|
||||||
<< DoubleVal.convertToDouble() << '\n';
|
<< DoubleVal.convertToDouble() << '\n';
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0])
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next halfword\n";
|
<< " long double next halfword\n";
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 16)
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next halfword\n";
|
<< " long double next halfword\n";
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32)
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next halfword\n";
|
<< " long double next halfword\n";
|
||||||
O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48)
|
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double most significant halfword\n";
|
<< " long double most significant halfword\n";
|
||||||
}
|
}
|
||||||
EmitZeros(TD->getTypePaddedSize(Type::X86_FP80Ty) -
|
EmitZeros(TD->getTypePaddedSize(Type::X86_FP80Ty) -
|
||||||
TD->getTypeStoreSize(Type::X86_FP80Ty));
|
TD->getTypeStoreSize(Type::X86_FP80Ty), AddrSpace);
|
||||||
return;
|
return;
|
||||||
} else if (CFP->getType() == Type::PPC_FP128Ty) {
|
} else if (CFP->getType() == Type::PPC_FP128Ty) {
|
||||||
// all long double variants are printed as hex
|
// all long double variants are printed as hex
|
||||||
@ -1069,29 +1071,29 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP) {
|
|||||||
APInt api = CFP->getValueAPF().bitcastToAPInt();
|
APInt api = CFP->getValueAPF().bitcastToAPInt();
|
||||||
const uint64_t *p = api.getRawData();
|
const uint64_t *p = api.getRawData();
|
||||||
if (TD->isBigEndian()) {
|
if (TD->isBigEndian()) {
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[0] >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double most significant word\n";
|
<< " long double most significant word\n";
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[0])
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next word\n";
|
<< " long double next word\n";
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[1] >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next word\n";
|
<< " long double next word\n";
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[1])
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double least significant word\n";
|
<< " long double least significant word\n";
|
||||||
} else {
|
} else {
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[1])
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double least significant word\n";
|
<< " long double least significant word\n";
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[1] >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next word\n";
|
<< " long double next word\n";
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[0])
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0])
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double next word\n";
|
<< " long double next word\n";
|
||||||
O << TAI->getData32bitsDirective() << uint32_t(p[0] >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " long double most significant word\n";
|
<< " long double most significant word\n";
|
||||||
}
|
}
|
||||||
@ -1099,7 +1101,8 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP) {
|
|||||||
} else assert(0 && "Floating point constant type not handled");
|
} else assert(0 && "Floating point constant type not handled");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI) {
|
void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI,
|
||||||
|
unsigned AddrSpace) {
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
unsigned BitWidth = CI->getBitWidth();
|
unsigned BitWidth = CI->getBitWidth();
|
||||||
assert(isPowerOf2_32(BitWidth) &&
|
assert(isPowerOf2_32(BitWidth) &&
|
||||||
@ -1116,20 +1119,20 @@ void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI) {
|
|||||||
else
|
else
|
||||||
Val = RawData[i];
|
Val = RawData[i];
|
||||||
|
|
||||||
if (TAI->getData64bitsDirective())
|
if (TAI->getData64bitsDirective(AddrSpace))
|
||||||
O << TAI->getData64bitsDirective() << Val << '\n';
|
O << TAI->getData64bitsDirective(AddrSpace) << Val << '\n';
|
||||||
else if (TD->isBigEndian()) {
|
else if (TD->isBigEndian()) {
|
||||||
O << TAI->getData32bitsDirective() << unsigned(Val >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " Double-word most significant word " << Val << '\n';
|
<< " Double-word most significant word " << Val << '\n';
|
||||||
O << TAI->getData32bitsDirective() << unsigned(Val)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " Double-word least significant word " << Val << '\n';
|
<< " Double-word least significant word " << Val << '\n';
|
||||||
} else {
|
} else {
|
||||||
O << TAI->getData32bitsDirective() << unsigned(Val)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " Double-word least significant word " << Val << '\n';
|
<< " Double-word least significant word " << Val << '\n';
|
||||||
O << TAI->getData32bitsDirective() << unsigned(Val >> 32)
|
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32)
|
||||||
<< '\t' << TAI->getCommentString()
|
<< '\t' << TAI->getCommentString()
|
||||||
<< " Double-word most significant word " << Val << '\n';
|
<< " Double-word most significant word " << Val << '\n';
|
||||||
}
|
}
|
||||||
@ -1137,27 +1140,27 @@ void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
||||||
void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) {
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
const Type *type = CV->getType();
|
const Type *type = CV->getType();
|
||||||
unsigned Size = TD->getTypePaddedSize(type);
|
unsigned Size = TD->getTypePaddedSize(type);
|
||||||
|
|
||||||
if (CV->isNullValue() || isa<UndefValue>(CV)) {
|
if (CV->isNullValue() || isa<UndefValue>(CV)) {
|
||||||
EmitZeros(Size);
|
EmitZeros(Size, AddrSpace);
|
||||||
return;
|
return;
|
||||||
} else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
|
} else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
|
||||||
EmitGlobalConstantArray(CVA);
|
EmitGlobalConstantArray(CVA);
|
||||||
return;
|
return;
|
||||||
} else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
|
} else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
|
||||||
EmitGlobalConstantStruct(CVS);
|
EmitGlobalConstantStruct(CVS, AddrSpace);
|
||||||
return;
|
return;
|
||||||
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
|
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
|
||||||
EmitGlobalConstantFP(CFP);
|
EmitGlobalConstantFP(CFP, AddrSpace);
|
||||||
return;
|
return;
|
||||||
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||||
// Small integers are handled below; large integers are handled here.
|
// Small integers are handled below; large integers are handled here.
|
||||||
if (Size > 4) {
|
if (Size > 4) {
|
||||||
EmitGlobalConstantLargeInt(CI);
|
EmitGlobalConstantLargeInt(CI, AddrSpace);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (const ConstantVector *CP = dyn_cast<ConstantVector>(CV)) {
|
} else if (const ConstantVector *CP = dyn_cast<ConstantVector>(CV)) {
|
||||||
@ -1165,7 +1168,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printDataDirective(type);
|
printDataDirective(type, AddrSpace);
|
||||||
EmitConstantValueOnly(CV);
|
EmitConstantValueOnly(CV);
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||||
SmallString<40> S;
|
SmallString<40> S;
|
||||||
@ -1491,21 +1494,21 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
|
|||||||
|
|
||||||
/// printDataDirective - This method prints the asm directive for the
|
/// printDataDirective - This method prints the asm directive for the
|
||||||
/// specified type.
|
/// specified type.
|
||||||
void AsmPrinter::printDataDirective(const Type *type) {
|
void AsmPrinter::printDataDirective(const Type *type, unsigned AddrSpace) {
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
switch (type->getTypeID()) {
|
switch (type->getTypeID()) {
|
||||||
case Type::IntegerTyID: {
|
case Type::IntegerTyID: {
|
||||||
unsigned BitWidth = cast<IntegerType>(type)->getBitWidth();
|
unsigned BitWidth = cast<IntegerType>(type)->getBitWidth();
|
||||||
if (BitWidth <= 8)
|
if (BitWidth <= 8)
|
||||||
O << TAI->getData8bitsDirective();
|
O << TAI->getData8bitsDirective(AddrSpace);
|
||||||
else if (BitWidth <= 16)
|
else if (BitWidth <= 16)
|
||||||
O << TAI->getData16bitsDirective();
|
O << TAI->getData16bitsDirective(AddrSpace);
|
||||||
else if (BitWidth <= 32)
|
else if (BitWidth <= 32)
|
||||||
O << TAI->getData32bitsDirective();
|
O << TAI->getData32bitsDirective(AddrSpace);
|
||||||
else if (BitWidth <= 64) {
|
else if (BitWidth <= 64) {
|
||||||
assert(TAI->getData64bitsDirective() &&
|
assert(TAI->getData64bitsDirective(AddrSpace) &&
|
||||||
"Target cannot handle 64-bit constant exprs!");
|
"Target cannot handle 64-bit constant exprs!");
|
||||||
O << TAI->getData64bitsDirective();
|
O << TAI->getData64bitsDirective(AddrSpace);
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "Target cannot handle given data directive width!");
|
assert(0 && "Target cannot handle given data directive width!");
|
||||||
}
|
}
|
||||||
@ -1513,15 +1516,15 @@ void AsmPrinter::printDataDirective(const Type *type) {
|
|||||||
}
|
}
|
||||||
case Type::PointerTyID:
|
case Type::PointerTyID:
|
||||||
if (TD->getPointerSize() == 8) {
|
if (TD->getPointerSize() == 8) {
|
||||||
assert(TAI->getData64bitsDirective() &&
|
assert(TAI->getData64bitsDirective(AddrSpace) &&
|
||||||
"Target cannot handle 64-bit pointer exprs!");
|
"Target cannot handle 64-bit pointer exprs!");
|
||||||
O << TAI->getData64bitsDirective();
|
O << TAI->getData64bitsDirective(AddrSpace);
|
||||||
} else if (TD->getPointerSize() == 2) {
|
} else if (TD->getPointerSize() == 2) {
|
||||||
O << TAI->getData16bitsDirective();
|
O << TAI->getData16bitsDirective(AddrSpace);
|
||||||
} else if (TD->getPointerSize() == 1) {
|
} else if (TD->getPointerSize() == 1) {
|
||||||
O << TAI->getData8bitsDirective();
|
O << TAI->getData8bitsDirective(AddrSpace);
|
||||||
} else {
|
} else {
|
||||||
O << TAI->getData32bitsDirective();
|
O << TAI->getData32bitsDirective(AddrSpace);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Type::FloatTyID: case Type::DoubleTyID:
|
case Type::FloatTyID: case Type::DoubleTyID:
|
||||||
|
@ -242,48 +242,11 @@ void PIC16AsmPrinter::EmitInitData (Module &M) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
O << name;
|
O << name;
|
||||||
EmitGlobalConstant(C);
|
EmitGlobalConstant(C, AddrSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIC16AsmPrinter::EmitConstantValueOnly(const Constant* CV) {
|
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
|
||||||
unsigned BitWidth = CI->getBitWidth();
|
|
||||||
int Val = CI->getZExtValue();
|
|
||||||
if (BitWidth == 8) {
|
|
||||||
// Expecting db directive here. In case of romdata we need to pad the
|
|
||||||
// word with zeros.
|
|
||||||
if (IsRomData)
|
|
||||||
O << 0 <<", ";
|
|
||||||
O << Val;
|
|
||||||
}
|
|
||||||
else if (BitWidth == 16) {
|
|
||||||
unsigned Element1, Element2;
|
|
||||||
Element1 = 0x00ff & Val;
|
|
||||||
Element2 = 0x00ff & (Val >> 8);
|
|
||||||
if (IsRomData)
|
|
||||||
O << 0 <<", "<<Element1 <<", "<< 0 <<", "<< Element2;
|
|
||||||
else
|
|
||||||
O << Element1 <<", "<< Element2;
|
|
||||||
}
|
|
||||||
else if (BitWidth == 32) {
|
|
||||||
unsigned Element1, Element2, Element3, Element4;
|
|
||||||
Element1 = 0x00ff & Val;
|
|
||||||
Element2 = 0x00ff & (Val >> 8);
|
|
||||||
Element3 = 0x00ff & (Val >> 16);
|
|
||||||
Element4 = 0x00ff & (Val >> 24);
|
|
||||||
if (IsRomData)
|
|
||||||
O << 0 <<", "<< Element1 <<", "<< 0 <<", "<< Element2 <<", "<< 0
|
|
||||||
<<", "<< Element3 <<", "<< 0 <<", "<< Element4;
|
|
||||||
else
|
|
||||||
O << Element1 <<", "<< Element2 <<", "<< Element3 <<", "<< Element4;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AsmPrinter::EmitConstantValueOnly(CV);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PIC16AsmPrinter::EmitRomData (Module &M)
|
void PIC16AsmPrinter::EmitRomData (Module &M)
|
||||||
{
|
{
|
||||||
SwitchToSection(TAI->getReadOnlySection());
|
SwitchToSection(TAI->getReadOnlySection());
|
||||||
@ -308,7 +271,7 @@ void PIC16AsmPrinter::EmitRomData (Module &M)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
O << name;
|
O << name;
|
||||||
EmitGlobalConstant(C);
|
EmitGlobalConstant(C, AddrSpace);
|
||||||
O << "\n";
|
O << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ namespace llvm {
|
|||||||
void EmitInitData (Module &M);
|
void EmitInitData (Module &M);
|
||||||
void EmitUnInitData (Module &M);
|
void EmitUnInitData (Module &M);
|
||||||
void EmitRomData (Module &M);
|
void EmitRomData (Module &M);
|
||||||
virtual void EmitConstantValueOnly(const Constant *CV);
|
|
||||||
void emitFunctionData(MachineFunction &MF);
|
void emitFunctionData(MachineFunction &MF);
|
||||||
void emitFunctionTempData(MachineFunction &MF, unsigned &FrameSize);
|
void emitFunctionTempData(MachineFunction &MF, unsigned &FrameSize);
|
||||||
|
|
||||||
|
@ -22,8 +22,11 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
|
|||||||
: TargetAsmInfo(TM) {
|
: TargetAsmInfo(TM) {
|
||||||
CommentString = ";";
|
CommentString = ";";
|
||||||
Data8bitsDirective = " db ";
|
Data8bitsDirective = " db ";
|
||||||
Data16bitsDirective = " db ";
|
Data16bitsDirective = " dw ";
|
||||||
Data32bitsDirective = " db ";
|
Data32bitsDirective = " dl ";
|
||||||
|
RomData8bitsDirective = " dw ";
|
||||||
|
RomData16bitsDirective = " rom_di ";
|
||||||
|
RomData8bitsDirective = " rom_dl ";
|
||||||
ZeroDirective = NULL;
|
ZeroDirective = NULL;
|
||||||
AsciiDirective = " dt ";
|
AsciiDirective = " dt ";
|
||||||
AscizDirective = NULL;
|
AscizDirective = NULL;
|
||||||
@ -33,3 +36,28 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
|
|||||||
DataSection = getNamedSection("idata.# IDATA", SectionFlags::Writeable);
|
DataSection = getNamedSection("idata.# IDATA", SectionFlags::Writeable);
|
||||||
SwitchToSectionDirective = "";
|
SwitchToSectionDirective = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *PIC16TargetAsmInfo::getData8bitsDirective(unsigned AddrSpace)
|
||||||
|
const {
|
||||||
|
if (AddrSpace == PIC16ISD::ROM_SPACE)
|
||||||
|
return RomData8bitsDirective;
|
||||||
|
else
|
||||||
|
return Data8bitsDirective;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *PIC16TargetAsmInfo::getData16bitsDirective(unsigned AddrSpace)
|
||||||
|
const {
|
||||||
|
if (AddrSpace == PIC16ISD::ROM_SPACE)
|
||||||
|
return RomData16bitsDirective;
|
||||||
|
else
|
||||||
|
return Data16bitsDirective;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *PIC16TargetAsmInfo::getData32bitsDirective(unsigned AddrSpace)
|
||||||
|
const {
|
||||||
|
if (AddrSpace == PIC16ISD::ROM_SPACE)
|
||||||
|
return RomData32bitsDirective;
|
||||||
|
else
|
||||||
|
return Data32bitsDirective;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,13 @@ namespace llvm {
|
|||||||
|
|
||||||
struct PIC16TargetAsmInfo : public TargetAsmInfo {
|
struct PIC16TargetAsmInfo : public TargetAsmInfo {
|
||||||
PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
|
PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
|
||||||
|
const char *RomData8bitsDirective;
|
||||||
|
const char *RomData16bitsDirective;
|
||||||
|
const char *RomData32bitsDirective;
|
||||||
public :
|
public :
|
||||||
|
virtual const char *getData8bitsDirective(unsigned AddrSpace = 0) const;
|
||||||
|
virtual const char *getData16bitsDirective(unsigned AddrSpace = 0) const;
|
||||||
|
virtual const char *getData32bitsDirective(unsigned AddrSpace = 0) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
Loading…
Reference in New Issue
Block a user