]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Add instruction definitions for drop and get/set_global.
authorDan Gohman <dan433584@gmail.com>
Thu, 2 Feb 2017 19:29:44 +0000 (19:29 +0000)
committerDan Gohman <dan433584@gmail.com>
Thu, 2 Feb 2017 19:29:44 +0000 (19:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
lib/Target/WebAssembly/WebAssemblyInstrInfo.td

index b4763ca60ab62555d4653a58df21e0205b0c5c9d..d5444b2a1d22f85398ec24a3a6febc9fe63b90ce 100644 (file)
@@ -94,6 +94,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction(
     switch (Info.OperandType) {
     case MCOI::OPERAND_IMMEDIATE:
     case WebAssembly::OPERAND_LOCAL:
+    case WebAssembly::OPERAND_GLOBAL:
     case WebAssembly::OPERAND_P2ALIGN:
     case WebAssembly::OPERAND_BASIC_BLOCK: {
       if (Pos + sizeof(uint64_t) > Bytes.size())
index 8583b772deab2b7bb59afc910173d2ac54ba1be2..64f8f7d4853dbc54d42d2d0e4936cafb4a32465e 100644 (file)
@@ -47,6 +47,8 @@ enum OperandType {
   OPERAND_BASIC_BLOCK = MCOI::OPERAND_FIRST_TARGET,
   /// Local index.
   OPERAND_LOCAL,
+  /// Global index.
+  OPERAND_GLOBAL,
   /// 32-bit integer immediates.
   OPERAND_I32IMM,
   /// 64-bit integer immediates.
index dcfd1a42c6aac65ec27c8e16cdaf84dd2f4408e3..79472cd8e48582de4c0254f0b615652de9557dc8 100644 (file)
@@ -74,6 +74,9 @@ def bb_op : Operand<OtherVT>;
 let OperandType = "OPERAND_LOCAL" in
 def local_op : Operand<i32>;
 
+let OperandType = "OPERAND_GLOBAL" in
+def global_op : Operand<i32>;
+
 let OperandType = "OPERAND_I32IMM" in
 def i32imm_op : Operand<i32>;
 
@@ -178,6 +181,18 @@ let hasSideEffects = 0 in {
   def TEE_LOCAL_#vt : I<(outs vt:$res), (ins local_op:$local, vt:$src), [],
                          "tee_local\t$res, $local, $src", 0x22>;
 
+  // Unused values must be dropped in some contexts.
+  def DROP_#vt : I<(outs), (ins vt:$src), [],
+                   "drop\t$src", 0x1a>;
+
+  let mayLoad = 1 in
+  def GET_GLOBAL_#vt : I<(outs vt:$res), (ins global_op:$local), [],
+                         "get_global\t$res, $local", 0x23>;
+
+  let mayStore = 1 in
+  def SET_GLOBAL_#vt : I<(outs), (ins global_op:$local, vt:$src), [],
+                         "set_global\t$local, $src", 0x24>;
+
 } // hasSideEffects = 0
 }
 defm : LOCAL<I32>;