mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-26 07:34:14 +00:00
Fix more naming issues.
compiler libcalls start with .lib. now. fixed section names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71424 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0608b49819
commit
e0b4b0e436
@ -72,11 +72,11 @@ namespace PIC16CC {
|
||||
// Its temp data: @foo.temp.
|
||||
// Its arg passing: @foo.args.
|
||||
//----------------------------------------------
|
||||
// Libcall - compiler generated libcall names must have a .lib.
|
||||
// Libcall - compiler generated libcall names must start with .lib.
|
||||
// This id will be used to emit extern decls for libcalls.
|
||||
// Example - libcall name: @sra_i8.lib.
|
||||
// To pass args: @sra_i8.args.
|
||||
// To return val: @sra_i8.ret.
|
||||
// Example - libcall name: @.lib.sra.i8
|
||||
// To pass args: @.lib.sra.i8.args.
|
||||
// To return val: @.lib.sra.i8.ret.
|
||||
//----------------------------------------------
|
||||
// SECTION Names
|
||||
// uninitialized globals - @udata.<num>.#
|
||||
@ -114,10 +114,10 @@ namespace PIC16CC {
|
||||
case TEMPS_LABEL: return ".temp.";
|
||||
case ARGS_LABEL: return ".args.";
|
||||
case RET_LABEL: return ".ret.";
|
||||
case LIBCALL: return "__intrinsics";
|
||||
case FRAME_SECTION: return ".fpdata.";
|
||||
case AUTOS_SECTION: return ".fadata.";
|
||||
case CODE_SECTION: return "code";
|
||||
case LIBCALL: return ".lib.";
|
||||
case FRAME_SECTION: return ".frame_section.";
|
||||
case AUTOS_SECTION: return ".autos_section.";
|
||||
case CODE_SECTION: return ".code_section.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,19 +205,19 @@ namespace PIC16CC {
|
||||
static std::string getFrameSectionName(const std::string &Func) {
|
||||
std::string Func1 = addPrefix(Func);
|
||||
std::string tag = getTagName(FRAME_SECTION);
|
||||
return Func1 + tag + " UDATA_OVR";
|
||||
return Func1 + tag + "# UDATA_OVR";
|
||||
}
|
||||
|
||||
static std::string getAutosSectionName(const std::string &Func) {
|
||||
std::string Func1 = addPrefix(Func);
|
||||
std::string tag = getTagName(AUTOS_SECTION);
|
||||
return Func1 + tag + " UDATA_OVR";
|
||||
return Func1 + tag + "# UDATA_OVR";
|
||||
}
|
||||
|
||||
static std::string getCodeSectionName(const std::string &Func) {
|
||||
std::string Func1 = addPrefix(Func);
|
||||
std::string tag = getTagName(CODE_SECTION);
|
||||
return Func1 + tag + " CODE";
|
||||
return Func1 + tag + "# CODE";
|
||||
}
|
||||
|
||||
// udata and idata section names are generated by a given number.
|
||||
@ -235,7 +235,15 @@ namespace PIC16CC {
|
||||
}
|
||||
|
||||
static std::string getDeclSectionName(void) {
|
||||
std::string dsname = "decl_section.1";
|
||||
std::string dsname = "section.0";
|
||||
dsname = addPrefix(dsname);
|
||||
return dsname;
|
||||
}
|
||||
|
||||
// FIXME: currently decls for libcalls are into a separate section.
|
||||
// merge the rest of decls to one.
|
||||
static std::string getLibDeclSectionName(void) {
|
||||
std::string dsname = "lib_decls.0";
|
||||
dsname = addPrefix(dsname);
|
||||
return dsname;
|
||||
}
|
||||
@ -285,7 +293,6 @@ namespace PIC16CC {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}; // class PAN.
|
||||
|
||||
|
||||
|
@ -157,7 +157,7 @@ void PIC16AsmPrinter::printDecls(void) {
|
||||
// If no libcalls used, return.
|
||||
if (Decls.empty()) return;
|
||||
|
||||
const Section *S = TAI->getNamedSection(PAN::getDeclSectionName().c_str());
|
||||
const Section *S = TAI->getNamedSection(PAN::getLibDeclSectionName().c_str());
|
||||
SwitchToSection(S);
|
||||
// Remove duplicate entries.
|
||||
Decls.sort();
|
||||
@ -166,8 +166,8 @@ void PIC16AsmPrinter::printDecls(void) {
|
||||
I != Decls.end(); I++) {
|
||||
O << TAI->getExternDirective() << *I << "\n";
|
||||
// FIXME: Use PAN::getXXXLabel() funtions hrer.
|
||||
O << TAI->getExternDirective() << *I << ".args." << "\n";
|
||||
O << TAI->getExternDirective() << *I << ".ret." << "\n";
|
||||
O << TAI->getExternDirective() << PAN::getArgsLabel(*I) << "\n";
|
||||
O << TAI->getExternDirective() << PAN::getRetvalLabel(*I) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ bool PIC16AsmPrinter::doInitialization (Module &M) {
|
||||
|
||||
void PIC16AsmPrinter::EmitExternsAndGlobals (Module &M) {
|
||||
// Emit declarations for external functions.
|
||||
O << "section.0" <<"\n";
|
||||
O << PAN::getDeclSectionName() <<"\n";
|
||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) {
|
||||
std::string Name = Mang->getValueName(I);
|
||||
if (Name.compare("@abort") == 0)
|
||||
|
@ -27,6 +27,38 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static const char *getIntrinsicName(unsigned opcode) {
|
||||
std::string Basename;
|
||||
switch(opcode) {
|
||||
default: assert (0 && "do not know intrinsic name");
|
||||
case PIC16ISD::SRA_I8: Basename = "sra.i8"; break;
|
||||
case RTLIB::SRA_I16: Basename = "sra.i16"; break;
|
||||
case RTLIB::SRA_I32: Basename = "sra.i32"; break;
|
||||
|
||||
case PIC16ISD::SLL_I8: Basename = "sll.i8"; break;
|
||||
case RTLIB::SHL_I16: Basename = "sll.i16"; break;
|
||||
case RTLIB::SHL_I32: Basename = "sll.i32"; break;
|
||||
|
||||
case PIC16ISD::SRL_I8: Basename = "srl.i8"; break;
|
||||
case RTLIB::SRL_I16: Basename = "srl.i16"; break;
|
||||
case RTLIB::SRL_I32: Basename = "srl.i32"; break;
|
||||
|
||||
case PIC16ISD::MUL_I8: Basename = "mul.i8"; break;
|
||||
case RTLIB::MUL_I16: Basename = "mul.i16"; break;
|
||||
case RTLIB::MUL_I32: Basename = "mul.i32"; break;
|
||||
}
|
||||
|
||||
std::string prefix = PAN::getTagName(PAN::PREFIX_SYMBOL);
|
||||
std::string tagname = PAN::getTagName(PAN::LIBCALL);
|
||||
std::string Fullname = prefix + tagname + Basename;
|
||||
|
||||
// The name has to live through program life.
|
||||
char *tmp = new char[Fullname.size() + 1];
|
||||
strcpy (tmp, Fullname.c_str());
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// PIC16TargetLowering Constructor.
|
||||
PIC16TargetLowering::PIC16TargetLowering(PIC16TargetMachine &TM)
|
||||
: TargetLowering(TM), TmpSize(0) {
|
||||
@ -39,24 +71,24 @@ PIC16TargetLowering::PIC16TargetLowering(PIC16TargetMachine &TM)
|
||||
setShiftAmountFlavor(Extend);
|
||||
|
||||
// SRA library call names
|
||||
setPIC16LibcallName(PIC16ISD::SRA_I8, "@__intrinsics.sra.i8");
|
||||
setLibcallName(RTLIB::SRA_I16, "@__intrinsics.sra.i16");
|
||||
setLibcallName(RTLIB::SRA_I32, "@__intrinsics.sra.i32");
|
||||
setPIC16LibcallName(PIC16ISD::SRA_I8, getIntrinsicName(PIC16ISD::SRA_I8));
|
||||
setLibcallName(RTLIB::SRA_I16, getIntrinsicName(RTLIB::SRA_I16));
|
||||
setLibcallName(RTLIB::SRA_I32, getIntrinsicName(RTLIB::SRA_I32));
|
||||
|
||||
// SHL library call names
|
||||
setPIC16LibcallName(PIC16ISD::SLL_I8, "@__intrinsics.sll.i8");
|
||||
setLibcallName(RTLIB::SHL_I16, "@__intrinsics.sll.i16");
|
||||
setLibcallName(RTLIB::SHL_I32, "@__intrinsics.sll.i32");
|
||||
setPIC16LibcallName(PIC16ISD::SLL_I8, getIntrinsicName(PIC16ISD::SLL_I8));
|
||||
setLibcallName(RTLIB::SHL_I16, getIntrinsicName(RTLIB::SHL_I16));
|
||||
setLibcallName(RTLIB::SHL_I32, getIntrinsicName(RTLIB::SHL_I32));
|
||||
|
||||
// SRL library call names
|
||||
setPIC16LibcallName(PIC16ISD::SRL_I8, "@__intrinsics.srl.i8");
|
||||
setLibcallName(RTLIB::SRL_I16, "@__intrinsics.srl.i16");
|
||||
setLibcallName(RTLIB::SRL_I32, "@__intrinsics.srl.i32");
|
||||
setPIC16LibcallName(PIC16ISD::SRL_I8, getIntrinsicName(PIC16ISD::SRL_I8));
|
||||
setLibcallName(RTLIB::SRL_I16, getIntrinsicName(RTLIB::SRL_I16));
|
||||
setLibcallName(RTLIB::SRL_I32, getIntrinsicName(RTLIB::SRL_I32));
|
||||
|
||||
// MUL Library call names
|
||||
setPIC16LibcallName(PIC16ISD::MUL_I8, "@__intrinsics.mul.i8");
|
||||
setLibcallName(RTLIB::MUL_I16, "@__intrinsics.mul.i16");
|
||||
setLibcallName(RTLIB::MUL_I32, "@__intrinsics.mul.i32");
|
||||
setPIC16LibcallName(PIC16ISD::MUL_I8, getIntrinsicName(PIC16ISD::MUL_I8));
|
||||
setLibcallName(RTLIB::MUL_I16, getIntrinsicName(RTLIB::MUL_I16));
|
||||
setLibcallName(RTLIB::MUL_I32, getIntrinsicName(RTLIB::MUL_I32));
|
||||
|
||||
setOperationAction(ISD::GlobalAddress, MVT::i16, Custom);
|
||||
setOperationAction(ISD::ExternalSymbol, MVT::i16, Custom);
|
||||
|
@ -61,7 +61,7 @@ namespace llvm {
|
||||
ROM_SPACE = 1 // ROM address space number is 1
|
||||
};
|
||||
enum PIC16Libcall {
|
||||
MUL_I8,
|
||||
MUL_I8 = RTLIB::UNKNOWN_LIBCALL + 1,
|
||||
SRA_I8,
|
||||
SLL_I8,
|
||||
SRL_I8,
|
||||
|
Loading…
x
Reference in New Issue
Block a user