Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 21 additions & 31 deletions llvm/utils/TableGen/CallingConvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Common/CodeGenTarget.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/InterleavedRange.h"
#include "llvm/TableGen/CodeGenHelpers.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TGTimer.h"
Expand Down Expand Up @@ -54,6 +55,21 @@ class CallingConvEmitter {
};
} // End anonymous namespace

static void emitCCHeader(raw_ostream &O, const Record *CC, StringRef Suffix) {
unsigned Pad = CC->getName().size();
if (CC->getValueAsBit("Entry")) {
O << "bool llvm::";
Pad += 12;
} else {
O << "static bool ";
Pad += 13;
}
O << CC->getName() << "(unsigned ValNo, MVT ValVT,\n"
<< indent(Pad) << "MVT LocVT, CCValAssign::LocInfo LocInfo,\n"
<< indent(Pad) << "ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)"
<< Suffix;
}

void CallingConvEmitter::run(raw_ostream &O) {
emitSourceFileHeader("Calling Convention Implementation Fragment", O);

Expand All @@ -63,35 +79,20 @@ void CallingConvEmitter::run(raw_ostream &O) {
// Emit prototypes for all of the non-custom CC's so that they can forward ref
// each other.
Records.getTimer().startTimer("Emit prototypes");
O << "#ifndef GET_CC_REGISTER_LISTS\n\n";
IfGuardEmitter IfGuard(O, "!defined(GET_CC_REGISTER_LISTS)");
for (const Record *CC : CCs) {
if (!CC->getValueAsBit("Custom")) {
unsigned Pad = CC->getName().size();
if (CC->getValueAsBit("Entry")) {
O << "bool llvm::";
Pad += 12;
} else {
O << "static bool ";
Pad += 13;
}
O << CC->getName() << "(unsigned ValNo, MVT ValVT,\n"
<< std::string(Pad, ' ') << "MVT LocVT, CCValAssign::LocInfo LocInfo,\n"
<< std::string(Pad, ' ')
<< "ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State);\n";
}
if (!CC->getValueAsBit("Custom"))
emitCCHeader(O, CC, ";\n");
}

// Emit each non-custom calling convention description in full.
Records.getTimer().startTimer("Emit full descriptions");
for (const Record *CC : CCs) {
if (!CC->getValueAsBit("Custom")) {
if (!CC->getValueAsBit("Custom"))
emitCallingConv(CC, O);
}
}

emitArgRegisterLists(O);

O << "\n#endif // CC_REGISTER_LIST\n";
}

void CallingConvEmitter::emitCallingConv(const Record *CC, raw_ostream &O) {
Expand All @@ -105,18 +106,7 @@ void CallingConvEmitter::emitCallingConv(const Record *CC, raw_ostream &O) {
AssignedRegsMap[CurrentAction] = {};

O << "\n\n";
unsigned Pad = CurrentAction.size();
if (CC->getValueAsBit("Entry")) {
O << "bool llvm::";
Pad += 12;
} else {
O << "static bool ";
Pad += 13;
}
O << CurrentAction << "(unsigned ValNo, MVT ValVT,\n"
<< std::string(Pad, ' ') << "MVT LocVT, CCValAssign::LocInfo LocInfo,\n"
<< std::string(Pad, ' ') << "ISD::ArgFlagsTy ArgFlags, Type *OrigTy, "
<< "CCState &State) {\n";
emitCCHeader(O, CC, " {\n");
// Emit all of the actions, in order.
for (unsigned I = 0, E = CCActions->size(); I != E; ++I) {
const Record *Action = CCActions->getElementAsRecord(I);
Expand Down