summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-04-03 00:17:29 +0000
committerSam Clegg <sbc@chromium.org>2019-04-03 00:17:29 +0000
commitef4c66c1c83bbb58643c66b4e290a56e9991d5ca (patch)
treee125825662252315b073f6f8d392a9922191b1fa
parent4c1581e2da81d640c019c2d9a6618db9eb4e471e (diff)
downloadbcm5719-llvm-ef4c66c1c83bbb58643c66b4e290a56e9991d5ca.tar.gz
bcm5719-llvm-ef4c66c1c83bbb58643c66b4e290a56e9991d5ca.zip
[WebAssembly] Remove unneeded target operand flags
This change is in preparation for the addition of new target operand flags for new relocation types. Have a symbol type as part of the flag set makes it harder to use and AFAICT these are serving no purpose. Differential Revision: https://reviews.llvm.org/D60014 llvm-svn: 357548
-rw-r--r--llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h8
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp4
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp23
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp2
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp2
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp40
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.h3
7 files changed, 32 insertions, 50 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
index 7d12dd7633a..69c477bbbb5 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
@@ -90,15 +90,9 @@ namespace WebAssemblyII {
enum TOF {
MO_NO_FLAG = 0,
- // Flags to indicate the type of the symbol being referenced
- MO_SYMBOL_FUNCTION = 0x1,
- MO_SYMBOL_GLOBAL = 0x2,
- MO_SYMBOL_EVENT = 0x4,
- MO_SYMBOL_MASK = 0x7,
-
// Address of data symbol via a wasm global. This adds a level of indirection
// similar to the GOT on native platforms.
- MO_GOT = 0x8,
+ MO_GOT,
};
} // end namespace WebAssemblyII
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
index 0f4e1abc6d5..a1c567fa3c0 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
@@ -130,7 +130,7 @@ void WebAssemblyFrameLowering::writeSPToGlobal(
const char *ES = "__stack_pointer";
auto *SPSymbol = MF.createExternalSymbolName(ES);
BuildMI(MBB, InsertStore, DL, TII->get(WebAssembly::GLOBAL_SET_I32))
- .addExternalSymbol(SPSymbol, WebAssemblyII::MO_SYMBOL_GLOBAL)
+ .addExternalSymbol(SPSymbol)
.addReg(SrcReg);
}
@@ -177,7 +177,7 @@ void WebAssemblyFrameLowering::emitPrologue(MachineFunction &MF,
const char *ES = "__stack_pointer";
auto *SPSymbol = MF.createExternalSymbolName(ES);
BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::GLOBAL_GET_I32), SPReg)
- .addExternalSymbol(SPSymbol, WebAssemblyII::MO_SYMBOL_GLOBAL);
+ .addExternalSymbol(SPSymbol);
bool HasBP = hasBP(MF);
if (HasBP) {
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index dc9afb73a93..b5e9d9e9723 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -996,7 +996,7 @@ SDValue WebAssemblyTargetLowering::LowerGlobalAddress(SDValue Op,
if (GA->getAddressSpace() != 0)
fail(DL, DAG, "WebAssembly only expects the 0 address space");
- unsigned Flags = 0;
+ unsigned OperandFlags = 0;
if (isPositionIndependent()) {
const GlobalValue *GV = GA->getGlobal();
if (getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV)) {
@@ -1017,13 +1017,13 @@ SDValue WebAssemblyTargetLowering::LowerGlobalAddress(SDValue Op,
return DAG.getNode(ISD::ADD, DL, VT, BaseAddr, SymAddr);
} else {
- Flags |= WebAssemblyII::MO_GOT;
+ OperandFlags = WebAssemblyII::MO_GOT;
}
}
return DAG.getNode(WebAssemblyISD::Wrapper, DL, VT,
DAG.getTargetGlobalAddress(GA->getGlobal(), DL, VT,
- GA->getOffset(), Flags));
+ GA->getOffset(), OperandFlags));
}
SDValue
@@ -1034,15 +1034,8 @@ WebAssemblyTargetLowering::LowerExternalSymbol(SDValue Op,
EVT VT = Op.getValueType();
assert(ES->getTargetFlags() == 0 &&
"Unexpected target flags on generic ExternalSymbolSDNode");
- // Set the TargetFlags to MO_SYMBOL_FUNCTION which indicates that this is a
- // "function" symbol rather than a data symbol. We do this unconditionally
- // even though we don't know anything about the symbol other than its name,
- // because all external symbols used in target-independent SelectionDAG code
- // are for functions.
- return DAG.getNode(
- WebAssemblyISD::Wrapper, DL, VT,
- DAG.getTargetExternalSymbol(ES->getSymbol(), VT,
- WebAssemblyII::MO_SYMBOL_FUNCTION));
+ return DAG.getNode(WebAssemblyISD::Wrapper, DL, VT,
+ DAG.getTargetExternalSymbol(ES->getSymbol(), VT));
}
SDValue WebAssemblyTargetLowering::LowerJumpTable(SDValue Op,
@@ -1136,10 +1129,8 @@ SDValue WebAssemblyTargetLowering::LowerIntrinsic(SDValue Op,
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
MVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
const char *SymName = MF.createExternalSymbolName("__cpp_exception");
- SDValue SymNode =
- DAG.getNode(WebAssemblyISD::Wrapper, DL, PtrVT,
- DAG.getTargetExternalSymbol(
- SymName, PtrVT, WebAssemblyII::MO_SYMBOL_EVENT));
+ SDValue SymNode = DAG.getNode(WebAssemblyISD::Wrapper, DL, PtrVT,
+ DAG.getTargetExternalSymbol(SymName, PtrVT));
return DAG.getNode(WebAssemblyISD::THROW, DL,
MVT::Other, // outchain type
{
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
index 3f5aba087f0..ee698113552 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
@@ -199,7 +199,7 @@ unsigned WebAssemblyInstrInfo::insertBranch(
const char *CPPExnSymbol = MF.createExternalSymbolName("__cpp_exception");
BuildMI(&MBB, DL, get(WebAssembly::BR_ON_EXN))
.addMBB(TBB)
- .addExternalSymbol(CPPExnSymbol, WebAssemblyII::MO_SYMBOL_EVENT)
+ .addExternalSymbol(CPPExnSymbol)
.add(Cond[1]);
} else
BuildMI(&MBB, DL, get(WebAssembly::BR_IF)).addMBB(TBB).add(Cond[1]);
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
index f365aa73792..49258ded766 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
@@ -307,7 +307,7 @@ bool WebAssemblyLateEHPrepare::addExceptionExtraction(MachineFunction &MF) {
const char *CPPExnSymbol = MF.createExternalSymbolName("__cpp_exception");
BuildMI(EHPad, DL, TII.get(WebAssembly::BR_ON_EXN))
.addMBB(ThenMBB)
- .addExternalSymbol(CPPExnSymbol, WebAssemblyII::MO_SYMBOL_EVENT)
+ .addExternalSymbol(CPPExnSymbol)
.addReg(ExnReg);
BuildMI(EHPad, DL, TII.get(WebAssembly::BR)).addMBB(ElseMBB);
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
index 9ca97796ac3..fd09b749c73 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
@@ -120,26 +120,27 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
return WasmSym;
}
-MCOperand WebAssemblyMCInstLower::lowerSymbolOperand(
- MCSymbol *Sym, int64_t Offset, bool IsFunc, unsigned TargetFlags) const {
- MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
- if (TargetFlags & WebAssemblyII::MO_GOT)
- Kind = MCSymbolRefExpr::VK_GOT;
+MCOperand WebAssemblyMCInstLower::lowerSymbolOperand(const MachineOperand &MO,
+ MCSymbol *Sym) const {
+ bool isGOT = MO.getTargetFlags() == WebAssemblyII::MO_GOT;
+ MCSymbolRefExpr::VariantKind Kind =
+ isGOT ? MCSymbolRefExpr::VK_GOT : MCSymbolRefExpr::VK_None;
const MCExpr *Expr = MCSymbolRefExpr::create(Sym, Kind, Ctx);
- if (Offset != 0) {
- if (TargetFlags & WebAssemblyII::MO_GOT)
+ if (MO.getOffset() != 0) {
+ const auto *WasmSym = cast<MCSymbolWasm>(Sym);
+ if (isGOT)
report_fatal_error("GOT symbol references do not support offsets");
- unsigned Type = TargetFlags & WebAssemblyII::MO_SYMBOL_MASK;
- assert((Type == WebAssemblyII::MO_SYMBOL_FUNCTION) == IsFunc);
- if (Type == WebAssemblyII::MO_SYMBOL_FUNCTION || IsFunc)
+
+ if (WasmSym->isFunction())
report_fatal_error("Function addresses with offsets not supported");
- if (Type == WebAssemblyII::MO_SYMBOL_GLOBAL)
+ if (WasmSym->isGlobal())
report_fatal_error("Global indexes with offsets not supported");
- if (Type == WebAssemblyII::MO_SYMBOL_EVENT)
+ if (WasmSym->isEvent())
report_fatal_error("Event indexes with offsets not supported");
- Expr =
- MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, Ctx), Ctx);
+
+ Expr = MCBinaryExpr::createAdd(
+ Expr, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
}
return MCOperand::createExpr(Expr);
@@ -236,24 +237,21 @@ void WebAssemblyMCInstLower::lower(const MachineInstr *MI,
break;
}
case MachineOperand::MO_GlobalAddress:
- MCOp = lowerSymbolOperand(GetGlobalAddressSymbol(MO), MO.getOffset(),
- MO.getGlobal()->getValueType()->isFunctionTy(),
- MO.getTargetFlags());
+ MCOp = lowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
break;
case MachineOperand::MO_ExternalSymbol:
// The target flag indicates whether this is a symbol for a
// variable or a function.
- assert((MO.getTargetFlags() & ~WebAssemblyII::MO_SYMBOL_MASK) == 0 &&
+ assert(MO.getTargetFlags() == 0 &&
"WebAssembly uses only symbol flags on ExternalSymbols");
- MCOp = lowerSymbolOperand(
- GetExternalSymbolSymbol(MO), /*Offset=*/0, false, MO.getTargetFlags());
+ MCOp = lowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
break;
case MachineOperand::MO_MCSymbol:
// This is currently used only for LSDA symbols (GCC_except_table),
// because global addresses or other external symbols are handled above.
assert(MO.getTargetFlags() == 0 &&
"WebAssembly does not use target flags on MCSymbol");
- MCOp = lowerSymbolOperand(MO.getMCSymbol(), /*Offset=*/0, false, MO.getTargetFlags());
+ MCOp = lowerSymbolOperand(MO, MO.getMCSymbol());
break;
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.h b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
index 125ba1dcfa5..2c375a01a7f 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
@@ -32,8 +32,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyMCInstLower {
MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
- MCOperand lowerSymbolOperand(MCSymbol *Sym, int64_t Offset, bool IsFunc,
- unsigned flags) const;
+ MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
public:
WebAssemblyMCInstLower(MCContext &ctx, WebAssemblyAsmPrinter &printer)
OpenPOWER on IntegriCloud