diff options
| author | Dan Gohman <dan433584@gmail.com> | 2017-02-24 23:18:00 +0000 |
|---|---|---|
| committer | Dan Gohman <dan433584@gmail.com> | 2017-02-24 23:18:00 +0000 |
| commit | d934cb8806dbddcbdf70fadf9b125af626fbcac3 (patch) | |
| tree | 9791d4ffccafec115dbadb7e1f9cce94963dbc1c /llvm/lib/MC/MCWasmStreamer.cpp | |
| parent | fb34a35c4eb11d30d9ba225c9daf84cf63f100fb (diff) | |
| download | bcm5719-llvm-d934cb8806dbddcbdf70fadf9b125af626fbcac3.tar.gz bcm5719-llvm-d934cb8806dbddcbdf70fadf9b125af626fbcac3.zip | |
[WebAssembly] Basic support for Wasm object file encoding.
With the "wasm32-unknown-unknown-wasm" triple, this allows writing out
simple wasm object files, and is another step in a larger series toward
migrating from ELF to general wasm object support. Note that this code
and the binary format itself is still experimental.
llvm-svn: 296190
Diffstat (limited to 'llvm/lib/MC/MCWasmStreamer.cpp')
| -rw-r--r-- | llvm/lib/MC/MCWasmStreamer.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp index f0a2f460a75..11a00adca65 100644 --- a/llvm/lib/MC/MCWasmStreamer.cpp +++ b/llvm/lib/MC/MCWasmStreamer.cpp @@ -89,7 +89,29 @@ bool MCWasmStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) { // the symbol with the assembler. getAssembler().registerSymbol(*Symbol); - // TODO: Set the symbol binding, type, etc. + switch (Attribute) { + case MCSA_LazyReference: + case MCSA_Reference: + case MCSA_SymbolResolver: + case MCSA_PrivateExtern: + case MCSA_WeakDefinition: + case MCSA_WeakDefAutoPrivate: + case MCSA_Invalid: + case MCSA_IndirectSymbol: + return false; + case MCSA_Global: + Symbol->setExternal(true); + break; + case MCSA_ELF_TypeFunction: + Symbol->setIsFunction(true); + break; + case MCSA_ELF_TypeObject: + Symbol->setIsFunction(false); + break; + default: + // unrecognized directive + return false; + } return true; } @@ -99,6 +121,10 @@ void MCWasmStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, llvm_unreachable("Common symbols are not yet implemented for Wasm"); } +void MCWasmStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) { + cast<MCSymbolWasm>(Symbol)->setSize(Value); +} + void MCWasmStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size, unsigned ByteAlignment) { llvm_unreachable("Local common symbols are not yet implemented for Wasm"); @@ -124,7 +150,17 @@ void MCWasmStreamer::EmitFileDirective(StringRef Filename) { } void MCWasmStreamer::EmitIdent(StringRef IdentString) { - llvm_unreachable("Ident sections not yet implemented for wasm"); + MCSection *Comment = getAssembler().getContext().getWasmSection( + ".comment", 0, 0); + PushSection(); + SwitchSection(Comment); + if (!SeenIdent) { + EmitIntValue(0, 1); + SeenIdent = true; + } + EmitBytes(IdentString); + EmitIntValue(0, 1); + PopSection(); } void MCWasmStreamer::EmitInstToFragment(const MCInst &Inst, |

