Fix more naming issues.

compiler libcalls start with .lib. now.
fixed section names.

llvm-svn: 71424
This commit is contained in:
Sanjiv Gupta 2009-05-11 08:52:04 +00:00
parent 9d175c15e7
commit ea5a8d8808
4 changed files with 69 additions and 30 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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);

View File

@ -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,