mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 14:20:17 +00:00
[WebAssembly] Rename member DefinedFunctions -> InputFunctions. NFC.
This avoids confusion with the `DefinedFunction` symbol type. Differential Revision: https://reviews.llvm.org/D43588 llvm-svn: 325705
This commit is contained in:
parent
25727a458c
commit
9f93422651
@ -122,7 +122,7 @@ private:
|
||||
std::vector<const DataSymbol *> ImportedGlobals;
|
||||
std::vector<WasmExportEntry> ExportedSymbols;
|
||||
std::vector<const DefinedData *> DefinedDataSymbols;
|
||||
std::vector<InputFunction *> DefinedFunctions;
|
||||
std::vector<InputFunction *> InputFunctions;
|
||||
std::vector<const FunctionSymbol *> IndirectFunctions;
|
||||
std::vector<WasmInitFunc> InitFunctions;
|
||||
|
||||
@ -202,14 +202,14 @@ void Writer::createTypeSection() {
|
||||
}
|
||||
|
||||
void Writer::createFunctionSection() {
|
||||
if (DefinedFunctions.empty())
|
||||
if (InputFunctions.empty())
|
||||
return;
|
||||
|
||||
SyntheticSection *Section = createSyntheticSection(WASM_SEC_FUNCTION);
|
||||
raw_ostream &OS = Section->getStream();
|
||||
|
||||
writeUleb128(OS, DefinedFunctions.size(), "function count");
|
||||
for (const InputFunction *Func : DefinedFunctions)
|
||||
writeUleb128(OS, InputFunctions.size(), "function count");
|
||||
for (const InputFunction *Func : InputFunctions)
|
||||
writeUleb128(OS, lookupType(Func->Signature), "sig index");
|
||||
}
|
||||
|
||||
@ -323,12 +323,12 @@ void Writer::createElemSection() {
|
||||
}
|
||||
|
||||
void Writer::createCodeSection() {
|
||||
if (DefinedFunctions.empty())
|
||||
if (InputFunctions.empty())
|
||||
return;
|
||||
|
||||
log("createCodeSection");
|
||||
|
||||
auto Section = make<CodeSection>(DefinedFunctions);
|
||||
auto Section = make<CodeSection>(InputFunctions);
|
||||
OutputSections.push_back(Section);
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ void Writer::createLinkingSection() {
|
||||
struct ComdatEntry { unsigned Kind; uint32_t Index; };
|
||||
std::map<StringRef,std::vector<ComdatEntry>> Comdats;
|
||||
|
||||
for (const InputFunction *F : DefinedFunctions) {
|
||||
for (const InputFunction *F : InputFunctions) {
|
||||
StringRef Comdat = F->getComdat();
|
||||
if (!Comdat.empty())
|
||||
Comdats[Comdat].emplace_back(
|
||||
@ -477,7 +477,7 @@ void Writer::createLinkingSection() {
|
||||
// Create the custom "name" section containing debug symbol names.
|
||||
void Writer::createNameSection() {
|
||||
unsigned NumNames = ImportedFunctions.size();
|
||||
for (const InputFunction *F : DefinedFunctions)
|
||||
for (const InputFunction *F : InputFunctions)
|
||||
if (!F->getName().empty())
|
||||
++NumNames;
|
||||
|
||||
@ -491,13 +491,13 @@ void Writer::createNameSection() {
|
||||
writeUleb128(OS, NumNames, "name count");
|
||||
|
||||
// Names must appear in function index order. As it happens ImportedFunctions
|
||||
// and DefinedFunctions are numbers in order with imported functions coming
|
||||
// and InputFunctions are numbers in order with imported functions coming
|
||||
// first.
|
||||
for (const Symbol *S : ImportedFunctions) {
|
||||
writeUleb128(OS, S->getOutputIndex(), "import index");
|
||||
writeStr(OS, S->getName(), "symbol name");
|
||||
}
|
||||
for (const InputFunction *F : DefinedFunctions) {
|
||||
for (const InputFunction *F : InputFunctions) {
|
||||
if (!F->getName().empty()) {
|
||||
writeUleb128(OS, F->getOutputIndex(), "func index");
|
||||
writeStr(OS, F->getName(), "symbol name");
|
||||
@ -714,13 +714,13 @@ void Writer::calculateTypes() {
|
||||
for (const FunctionSymbol *Sym : ImportedFunctions)
|
||||
registerType(*Sym->getFunctionType());
|
||||
|
||||
for (const InputFunction *F : DefinedFunctions)
|
||||
for (const InputFunction *F : InputFunctions)
|
||||
registerType(F->Signature);
|
||||
}
|
||||
|
||||
void Writer::assignIndexes() {
|
||||
uint32_t GlobalIndex = ImportedGlobals.size() + DefinedDataSymbols.size();
|
||||
uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size();
|
||||
uint32_t FunctionIndex = ImportedFunctions.size() + InputFunctions.size();
|
||||
|
||||
auto AddDefinedData = [&](DefinedData *Sym) {
|
||||
if (Sym) {
|
||||
@ -755,7 +755,7 @@ void Writer::assignIndexes() {
|
||||
for (InputFunction *Func : File->Functions) {
|
||||
if (!Func->Live)
|
||||
continue;
|
||||
DefinedFunctions.emplace_back(Func);
|
||||
InputFunctions.emplace_back(Func);
|
||||
Func->setOutputIndex(FunctionIndex++);
|
||||
}
|
||||
}
|
||||
@ -828,7 +828,7 @@ static const int OPCODE_END = 0xb;
|
||||
// Create synthetic "__wasm_call_ctors" function based on ctor functions
|
||||
// in input object.
|
||||
void Writer::createCtorFunction() {
|
||||
uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size();
|
||||
uint32_t FunctionIndex = ImportedFunctions.size() + InputFunctions.size();
|
||||
WasmSym::CallCtors->setOutputIndex(FunctionIndex);
|
||||
|
||||
// First write the body bytes to a string.
|
||||
@ -855,7 +855,7 @@ void Writer::createCtorFunction() {
|
||||
CtorFunction = llvm::make_unique<SyntheticFunction>(
|
||||
Signature, BodyArray, WasmSym::CallCtors->getName());
|
||||
CtorFunction->setOutputIndex(FunctionIndex);
|
||||
DefinedFunctions.emplace_back(CtorFunction.get());
|
||||
InputFunctions.emplace_back(CtorFunction.get());
|
||||
}
|
||||
|
||||
// Populate InitFunctions vector with init functions from all input objects.
|
||||
@ -892,7 +892,7 @@ void Writer::run() {
|
||||
calculateTypes();
|
||||
|
||||
if (errorHandler().Verbose) {
|
||||
log("Defined Functions: " + Twine(DefinedFunctions.size()));
|
||||
log("Defined Functions: " + Twine(InputFunctions.size()));
|
||||
log("Defined Data Syms: " + Twine(DefinedDataSymbols.size()));
|
||||
log("Function Imports : " + Twine(ImportedFunctions.size()));
|
||||
log("Global Imports : " + Twine(ImportedGlobals.size()));
|
||||
|
Loading…
Reference in New Issue
Block a user