aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
diff options
context:
space:
mode:
authorNicholas Wilson <nicholas@nicholaswilson.me.uk>2018-08-03 14:33:37 +0000
committerNicholas Wilson <nicholas@nicholaswilson.me.uk>2018-08-03 14:33:37 +0000
commite408a89a3aa83acb97f22d7d51ab341c22c6e05c (patch)
tree6b829861c534d9dc48c4940345183f528fe1c081 /llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
parent873de9866119754dab9146026f357a27bb1d5e26 (diff)
downloadllvm-e408a89a3aa83acb97f22d7d51ab341c22c6e05c.zip
llvm-e408a89a3aa83acb97f22d7d51ab341c22c6e05c.tar.gz
llvm-e408a89a3aa83acb97f22d7d51ab341c22c6e05c.tar.bz2
[WebAssembly] Cleanup of the way globals and global flags are handled
Differential Revision: https://reviews.llvm.org/D44030 llvm-svn: 338894
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
index d85db14..5a9e3c6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
@@ -108,9 +108,11 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
MCOperand WebAssemblyMCInstLower::LowerSymbolOperand(MCSymbol *Sym,
int64_t Offset,
- bool IsFunc) const {
+ bool IsFunc,
+ bool IsGlob) const {
MCSymbolRefExpr::VariantKind VK =
- IsFunc ? MCSymbolRefExpr::VK_WebAssembly_FUNCTION
+ IsFunc ? MCSymbolRefExpr::VK_WebAssembly_FUNCTION :
+ IsGlob ? MCSymbolRefExpr::VK_WebAssembly_GLOBAL
: MCSymbolRefExpr::VK_None;
const MCExpr *Expr = MCSymbolRefExpr::create(Sym, VK, Ctx);
@@ -118,6 +120,8 @@ MCOperand WebAssemblyMCInstLower::LowerSymbolOperand(MCSymbol *Sym,
if (Offset != 0) {
if (IsFunc)
report_fatal_error("Function addresses with offsets not supported");
+ if (IsGlob)
+ report_fatal_error("Global indexes with offsets not supported");
Expr =
MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, Ctx), Ctx);
}
@@ -212,18 +216,20 @@ void WebAssemblyMCInstLower::Lower(const MachineInstr *MI,
break;
}
case MachineOperand::MO_GlobalAddress:
- assert(MO.getTargetFlags() == 0 &&
+ assert(MO.getTargetFlags() == WebAssemblyII::MO_NO_FLAG &&
"WebAssembly does not use target flags on GlobalAddresses");
MCOp = LowerSymbolOperand(GetGlobalAddressSymbol(MO), MO.getOffset(),
- MO.getGlobal()->getValueType()->isFunctionTy());
+ MO.getGlobal()->getValueType()->isFunctionTy(),
+ false);
break;
case MachineOperand::MO_ExternalSymbol:
// The target flag indicates whether this is a symbol for a
// variable or a function.
- assert((MO.getTargetFlags() & -2) == 0 &&
- "WebAssembly uses only one target flag bit on ExternalSymbols");
+ assert((MO.getTargetFlags() & ~WebAssemblyII::MO_SYMBOL_MASK) == 0 &&
+ "WebAssembly uses only symbol flags on ExternalSymbols");
MCOp = LowerSymbolOperand(GetExternalSymbolSymbol(MO), /*Offset=*/0,
- MO.getTargetFlags() & 1);
+ (MO.getTargetFlags() & WebAssemblyII::MO_SYMBOL_FUNCTION) != 0,
+ (MO.getTargetFlags() & WebAssemblyII::MO_SYMBOL_GLOBAL) != 0);
break;
}