summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2018-09-05 01:27:38 +0000
committerHeejin Ahn <aheejin@gmail.com>2018-09-05 01:27:38 +0000
commitf208f6311b6ea3468b35deab208e307f8a59781b (patch)
tree24a733e46980c1385f08e5c6892bdfd85341cd1d /llvm/tools
parent5d05be84b7cdcb9160d49167ec78d4555a18f405 (diff)
downloadbcm5719-llvm-f208f6311b6ea3468b35deab208e307f8a59781b.tar.gz
bcm5719-llvm-f208f6311b6ea3468b35deab208e307f8a59781b.zip
[WebAssembly] clang-format (NFC)
Summary: This patch runs clang-format on all wasm-only files. Reviewers: aardappel, dschuff, sunfish, tlively Subscribers: MatzeB, sbc100, jgravelle-google, llvm-commits Differential Revision: https://reviews.llvm.org/D51447 llvm-svn: 341439
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-readobj/WasmDumper.cpp38
-rw-r--r--llvm/tools/obj2yaml/wasm2yaml.cpp15
-rw-r--r--llvm/tools/yaml2obj/yaml2wasm.cpp63
3 files changed, 56 insertions, 60 deletions
diff --git a/llvm/tools/llvm-readobj/WasmDumper.cpp b/llvm/tools/llvm-readobj/WasmDumper.cpp
index ce224836225..6f13bcda3ed 100644
--- a/llvm/tools/llvm-readobj/WasmDumper.cpp
+++ b/llvm/tools/llvm-readobj/WasmDumper.cpp
@@ -23,28 +23,22 @@ using namespace object;
namespace {
static const EnumEntry<unsigned> WasmSymbolTypes[] = {
-#define ENUM_ENTRY(X) { #X, wasm::WASM_SYMBOL_TYPE_##X }
- ENUM_ENTRY(FUNCTION),
- ENUM_ENTRY(DATA),
- ENUM_ENTRY(GLOBAL),
- ENUM_ENTRY(SECTION),
+#define ENUM_ENTRY(X) \
+ { #X, wasm::WASM_SYMBOL_TYPE_##X }
+ ENUM_ENTRY(FUNCTION),
+ ENUM_ENTRY(DATA),
+ ENUM_ENTRY(GLOBAL),
+ ENUM_ENTRY(SECTION),
#undef ENUM_ENTRY
};
static const EnumEntry<uint32_t> WasmSectionTypes[] = {
-#define ENUM_ENTRY(X) { #X, wasm::WASM_SEC_##X }
- ENUM_ENTRY(CUSTOM),
- ENUM_ENTRY(TYPE),
- ENUM_ENTRY(IMPORT),
- ENUM_ENTRY(FUNCTION),
- ENUM_ENTRY(TABLE),
- ENUM_ENTRY(MEMORY),
- ENUM_ENTRY(GLOBAL),
- ENUM_ENTRY(EXPORT),
- ENUM_ENTRY(START),
- ENUM_ENTRY(ELEM),
- ENUM_ENTRY(CODE),
- ENUM_ENTRY(DATA),
+#define ENUM_ENTRY(X) \
+ { #X, wasm::WASM_SEC_##X }
+ ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT),
+ ENUM_ENTRY(FUNCTION), ENUM_ENTRY(TABLE), ENUM_ENTRY(MEMORY),
+ ENUM_ENTRY(GLOBAL), ENUM_ENTRY(EXPORT), ENUM_ENTRY(START),
+ ENUM_ENTRY(ELEM), ENUM_ENTRY(CODE), ENUM_ENTRY(DATA),
#undef ENUM_ENTRY
};
@@ -108,7 +102,7 @@ void WasmDumper::printRelocation(const SectionRef &Section,
if (HasAddend)
W.printNumber("Addend", WasmReloc.Addend);
} else {
- raw_ostream& OS = W.startLine();
+ raw_ostream &OS = W.startLine();
OS << W.hex(Reloc.getOffset()) << " " << RelocTypeName << " ";
if (!SymName.empty())
OS << SymName;
@@ -169,7 +163,7 @@ void WasmDumper::printSections() {
const wasm::WasmLinkingData &LinkingData = Obj->linkingData();
if (!LinkingData.InitFunctions.empty()) {
ListScope Group(W, "InitFunctions");
- for (const wasm::WasmInitFunc &F: LinkingData.InitFunctions)
+ for (const wasm::WasmInitFunc &F : LinkingData.InitFunctions)
W.startLine() << F.Symbol << " (priority=" << F.Priority << ")\n";
}
}
@@ -177,7 +171,7 @@ void WasmDumper::printSections() {
case wasm::WASM_SEC_DATA: {
ListScope Group(W, "Segments");
for (const WasmSegment &Segment : Obj->dataSegments()) {
- const wasm::WasmDataSegment& Seg = Segment.Data;
+ const wasm::WasmDataSegment &Seg = Segment.Data;
DictScope Group(W, "Segment");
if (!Seg.Name.empty())
W.printString("Name", Seg.Name);
@@ -219,7 +213,7 @@ void WasmDumper::printSymbol(const SymbolRef &Sym) {
W.printHex("Flags", Symbol.Info.Flags);
}
-}
+} // namespace
namespace llvm {
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index dbaf1a2848f..ad91acaeb26 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -49,11 +49,13 @@ static WasmYAML::Limits make_limits(const wasm::WasmLimits &Limits) {
return L;
}
-std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
+std::unique_ptr<WasmYAML::CustomSection>
+WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
std::unique_ptr<WasmYAML::CustomSection> CustomSec;
if (WasmSec.Name == "name") {
- std::unique_ptr<WasmYAML::NameSection> NameSec = make_unique<WasmYAML::NameSection>();
- for (const llvm::wasm::WasmFunctionName &Func: Obj.debugNames()) {
+ std::unique_ptr<WasmYAML::NameSection> NameSec =
+ make_unique<WasmYAML::NameSection>();
+ for (const llvm::wasm::WasmFunctionName &Func : Obj.debugNames()) {
WasmYAML::NameEntry NameEntry;
NameEntry.Name = Func.Name;
NameEntry.Index = Func.Index;
@@ -61,7 +63,8 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
}
CustomSec = std::move(NameSec);
} else if (WasmSec.Name == "linking") {
- std::unique_ptr<WasmYAML::LinkingSection> LinkingSec = make_unique<WasmYAML::LinkingSection>();
+ std::unique_ptr<WasmYAML::LinkingSection> LinkingSec =
+ make_unique<WasmYAML::LinkingSection>();
LinkingSec->Version = Obj.linkingData().Version;
ArrayRef<StringRef> Comdats = Obj.linkingData().Comdats;
@@ -70,7 +73,7 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
for (auto &Func : Obj.functions()) {
if (Func.Comdat != UINT32_MAX) {
LinkingSec->Comdats[Func.Comdat].Entries.emplace_back(
- WasmYAML::ComdatEntry{wasm::WASM_COMDAT_FUNCTION, Func.Index});
+ WasmYAML::ComdatEntry{wasm::WASM_COMDAT_FUNCTION, Func.Index});
}
}
@@ -290,7 +293,7 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
llvm_unreachable("Unknown section type");
break;
}
- for (const wasm::WasmRelocation &Reloc: WasmSec.Relocations) {
+ for (const wasm::WasmRelocation &Reloc : WasmSec.Relocations) {
WasmYAML::Relocation R;
R.Type = Reloc.Type;
R.Index = Reloc.Index;
diff --git a/llvm/tools/yaml2obj/yaml2wasm.cpp b/llvm/tools/yaml2obj/yaml2wasm.cpp
index a7ec25e31c7..2b1e256f8f6 100644
--- a/llvm/tools/yaml2obj/yaml2wasm.cpp
+++ b/llvm/tools/yaml2obj/yaml2wasm.cpp
@@ -127,12 +127,11 @@ public:
OutString.clear();
}
- raw_ostream& GetStream() {
- return StringStream;
- }
+ raw_ostream &GetStream() { return StringStream; }
};
-int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &Section) {
+int WasmWriter::writeSectionContent(raw_ostream &OS,
+ WasmYAML::LinkingSection &Section) {
writeStringRef(Section.Name, OS);
encodeULEB128(Section.Version, OS);
@@ -218,7 +217,8 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &S
return 0;
}
-int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::NameSection &Section) {
+int WasmWriter::writeSectionContent(raw_ostream &OS,
+ WasmYAML::NameSection &Section) {
writeStringRef(Section.Name, OS);
if (Section.FunctionNames.size()) {
writeUint8(OS, wasm::WASM_NAMES_FUNCTION);
@@ -296,7 +296,7 @@ int WasmWriter::writeSectionContent(raw_ostream &OS,
writeLimits(Import.Memory, OS);
break;
case wasm::WASM_EXTERNAL_TABLE:
- writeUint8(OS,Import.TableImport.ElemType);
+ writeUint8(OS, Import.TableImport.ElemType);
writeLimits(Import.TableImport.TableLimits, OS);
break;
default:
@@ -428,47 +428,46 @@ int WasmWriter::writeSectionContent(raw_ostream &OS,
int WasmWriter::writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec,
uint32_t SectionIndex) {
switch (Sec.Type) {
- case wasm::WASM_SEC_CODE:
- writeStringRef("reloc.CODE", OS);
- break;
- case wasm::WASM_SEC_DATA:
- writeStringRef("reloc.DATA", OS);
- break;
- case wasm::WASM_SEC_CUSTOM: {
- auto CustomSection = dyn_cast<WasmYAML::CustomSection>(&Sec);
- if (!CustomSection->Name.startswith(".debug_")) {
- llvm_unreachable("not yet implemented (only for debug sections)");
- return 1;
- }
-
- writeStringRef(("reloc." + CustomSection->Name).str(), OS);
- break;
- }
- default:
- llvm_unreachable("not yet implemented");
+ case wasm::WASM_SEC_CODE:
+ writeStringRef("reloc.CODE", OS);
+ break;
+ case wasm::WASM_SEC_DATA:
+ writeStringRef("reloc.DATA", OS);
+ break;
+ case wasm::WASM_SEC_CUSTOM: {
+ auto CustomSection = dyn_cast<WasmYAML::CustomSection>(&Sec);
+ if (!CustomSection->Name.startswith(".debug_")) {
+ llvm_unreachable("not yet implemented (only for debug sections)");
return 1;
+ }
+
+ writeStringRef(("reloc." + CustomSection->Name).str(), OS);
+ break;
+ }
+ default:
+ llvm_unreachable("not yet implemented");
+ return 1;
}
encodeULEB128(SectionIndex, OS);
encodeULEB128(Sec.Relocations.size(), OS);
- for (auto Reloc: Sec.Relocations) {
+ for (auto Reloc : Sec.Relocations) {
writeUint8(OS, Reloc.Type);
encodeULEB128(Reloc.Offset, OS);
encodeULEB128(Reloc.Index, OS);
switch (Reloc.Type) {
- case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
- case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
- case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
- case wasm::R_WEBASSEMBLY_FUNCTION_OFFSET_I32:
- case wasm::R_WEBASSEMBLY_SECTION_OFFSET_I32:
- encodeULEB128(Reloc.Addend, OS);
+ case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
+ case wasm::R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
+ case wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32:
+ case wasm::R_WEBASSEMBLY_FUNCTION_OFFSET_I32:
+ case wasm::R_WEBASSEMBLY_SECTION_OFFSET_I32:
+ encodeULEB128(Reloc.Addend, OS);
}
}
return 0;
}
-
int WasmWriter::writeWasm(raw_ostream &OS) {
// Write headers
OS.write(wasm::WasmMagic, sizeof(wasm::WasmMagic));
OpenPOWER on IntegriCloud