-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[WebAssembly] Add WebAssembly::Specifier #133116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a727f9f
178dc3e
a2a1b26
f0da67f
f27e193
b6529dc
75d41e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "MCTargetDesc/WebAssemblyMCExpr.h" | ||
| #include "MCTargetDesc/WebAssemblyMCTypeUtilities.h" | ||
| #include "TargetInfo/WebAssemblyTargetInfo.h" | ||
| #include "llvm/BinaryFormat/Wasm.h" | ||
|
|
@@ -238,7 +239,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction( | |
| auto *WasmSym = cast<MCSymbolWasm>(Sym); | ||
| WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); | ||
| const MCExpr *Expr = MCSymbolRefExpr::create( | ||
| WasmSym, MCSymbolRefExpr::VK_WASM_TYPEINDEX, getContext()); | ||
| WasmSym, WebAssemblyMCExpr::VK_TYPEINDEX, getContext()); | ||
|
||
| MI.addOperand(MCOperand::createExpr(Expr)); | ||
| } | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| //===- WebAssembly specific MC expression classes ---------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "WebAssemblyMCExpr.h" | ||
| #include "llvm/MC/MCContext.h" | ||
| #include "llvm/MC/MCStreamer.h" | ||
| #include "llvm/MC/MCValue.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| const WebAssemblyMCExpr * | ||
| WebAssemblyMCExpr::create(const MCExpr *Expr, Specifier S, MCContext &Ctx) { | ||
| return new (Ctx) WebAssemblyMCExpr(Expr, S); | ||
| } | ||
|
|
||
| void WebAssemblyMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const { | ||
| } | ||
MaskRay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| bool WebAssemblyMCExpr::evaluateAsRelocatableImpl( | ||
| MCValue &Res, const MCAssembler *Asm) const { | ||
| if (!getSubExpr()->evaluateAsRelocatable(Res, Asm)) | ||
| return false; | ||
| Res.setSpecifier(specifier); | ||
| return !Res.getSubSym(); | ||
| } | ||
|
|
||
| void WebAssemblyMCExpr::visitUsedExpr(MCStreamer &S) const { | ||
| S.visitUsedExpr(*Expr); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| //===- WebAssembly specific MC expression classes ---------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // The MCTargetExpr subclass describes a relocatable expression with a | ||
| // WebAssembly-specific relocation specifier. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCEXPR_H | ||
| #define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCEXPR_H | ||
|
|
||
| #include "llvm/MC/MCExpr.h" | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class WebAssemblyMCExpr : public MCTargetExpr { | ||
| public: | ||
| enum Specifier { | ||
| VK_None, | ||
| VK_TYPEINDEX, | ||
| VK_TBREL, | ||
| VK_MBREL, | ||
| VK_TLSREL, | ||
| VK_GOT, | ||
| VK_GOT_TLS, | ||
| VK_FUNCINDEX, | ||
|
||
| }; | ||
|
|
||
| private: | ||
| const MCExpr *Expr; | ||
| const Specifier specifier; | ||
|
|
||
| protected: | ||
| explicit WebAssemblyMCExpr(const MCExpr *Expr, Specifier S) | ||
| : Expr(Expr), specifier(S) {} | ||
|
|
||
| public: | ||
| static const WebAssemblyMCExpr *create(const MCExpr *, Specifier, | ||
| MCContext &); | ||
|
|
||
| Specifier getSpecifier() const { return specifier; } | ||
| const MCExpr *getSubExpr() const { return Expr; } | ||
|
|
||
| void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; | ||
| bool evaluateAsRelocatableImpl(MCValue &Res, | ||
| const MCAssembler *Asm) const override; | ||
| void visitUsedExpr(MCStreamer &Streamer) const override; | ||
| MCFragment *findAssociatedFragment() const override { | ||
| return getSubExpr()->findAssociatedFragment(); | ||
| } | ||
| }; | ||
|
|
||
| static inline WebAssemblyMCExpr::Specifier | ||
| getSpecifier(const MCSymbolRefExpr *SRE) { | ||
| return WebAssemblyMCExpr::Specifier(SRE->getKind()); | ||
| } | ||
| } // namespace llvm | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.