diff options
author | Sam Clegg <sbc@chromium.org> | 2017-06-13 18:51:50 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-06-13 18:51:50 +0000 |
commit | ae03c1e7246adb5af0019d6005d2acfd74f6f40f (patch) | |
tree | 728be80277461eab8e20ae88596ef6a27d354228 /llvm/lib/Target/WebAssembly/MCTargetDesc | |
parent | 7db514064a1ad394aea8b4c544ae9988e131c0da (diff) | |
download | bcm5719-llvm-ae03c1e7246adb5af0019d6005d2acfd74f6f40f.tar.gz bcm5719-llvm-ae03c1e7246adb5af0019d6005d2acfd74f6f40f.zip |
[WebAssembly] Cleanup WebAssemblyWasmObjectWriter
Differential Revision: https://reviews.llvm.org/D34131
llvm-svn: 305316
Diffstat (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc')
-rw-r--r-- | llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h | 4 | ||||
-rw-r--r-- | llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp | 25 |
2 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h index ddf964e7dbb..5ad147e5e59 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h @@ -46,9 +46,7 @@ public: /// .functype virtual void emitIndirectFunctionType(StringRef name, SmallVectorImpl<MVT> &Params, - SmallVectorImpl<MVT> &Results) { - llvm_unreachable("emitIndirectFunctionType not implemented"); - } + SmallVectorImpl<MVT> &Results) = 0; /// .indidx virtual void emitIndIdx(const MCExpr *Value) = 0; /// .import_global diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp index 27c01cb8acf..19e14f3261a 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp @@ -16,11 +16,15 @@ #include "MCTargetDesc/WebAssemblyFixupKinds.h" #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "llvm/BinaryFormat/Wasm.h" +#include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCFixup.h" +#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCSymbolWasm.h" #include "llvm/MC/MCWasmObjectWriter.h" +#include "llvm/MC/MCValue.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" + using namespace llvm; namespace { @@ -29,8 +33,8 @@ public: explicit WebAssemblyWasmObjectWriter(bool Is64Bit); private: - unsigned getRelocType(MCContext &Ctx, const MCValue &Target, - const MCFixup &Fixup, bool IsPCRel) const override; + unsigned getRelocType(const MCValue &Target, + const MCFixup &Fixup) const override; }; } // end anonymous namespace @@ -39,16 +43,13 @@ WebAssemblyWasmObjectWriter::WebAssemblyWasmObjectWriter(bool Is64Bit) // Test whether the given expression computes a function address. static bool IsFunctionExpr(const MCExpr *Expr) { - if (const MCSymbolRefExpr *SyExp = - dyn_cast<MCSymbolRefExpr>(Expr)) + if (auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr)) return cast<MCSymbolWasm>(SyExp->getSymbol()).isFunction(); - if (const MCBinaryExpr *BinOp = - dyn_cast<MCBinaryExpr>(Expr)) + if (auto BinOp = dyn_cast<MCBinaryExpr>(Expr)) return IsFunctionExpr(BinOp->getLHS()) != IsFunctionExpr(BinOp->getRHS()); - if (const MCUnaryExpr *UnOp = - dyn_cast<MCUnaryExpr>(Expr)) + if (auto UnOp = dyn_cast<MCUnaryExpr>(Expr)) return IsFunctionExpr(UnOp->getSubExpr()); return false; @@ -59,15 +60,13 @@ static bool IsFunctionType(const MCValue &Target) { return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX; } -unsigned WebAssemblyWasmObjectWriter::getRelocType(MCContext &Ctx, - const MCValue &Target, - const MCFixup &Fixup, - bool IsPCRel) const { +unsigned +WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target, + const MCFixup &Fixup) const { // WebAssembly functions are not allocated in the data address space. To // resolve a pointer to a function, we must use a special relocation type. bool IsFunction = IsFunctionExpr(Fixup.getValue()); - assert(!IsPCRel); switch (unsigned(Fixup.getKind())) { case WebAssembly::fixup_code_sleb128_i32: if (IsFunction) |