LDPSW

Loads and stores

fixed bit field field the encoding fixes should be

Memory pair general post-index

313029282726252423222120191817161514131211109876543210
0110100011imm7Rt2RnRt
opcL

0110100011xxxxxxxxxxxxxxxxxxxxxx

Decode Sail

wback : bool = true;
let postindex : bool = true;
let 'n = UInt(Rn);
let 't = UInt(Rt);
let 't2 = UInt(Rt2);
let nontemporal : bool = false;
let memop : MemOp = if L == 0b1 then MemOp_LOAD else MemOp_STORE;
if (L @ [opc[0]]) == 0b01 | opc == 0b11 then {
    throw(Error_Undefined())
};
let is_signed : bool = [opc[0]] != 0b0;
let 'scale = 2 + UInt([opc[1]]);
let 'datasize = (8 << scale);
let offset : bits(64) = LSL(SignExtend(imm7, 64), scale);
let tagchecked : bool = wback | n != 31;
rt_unknown : bool = false;
wb_unknown : bool = false;
if ((memop == MemOp_LOAD & wback) & (t == n | t2 == n)) & n != 31 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_WBOVERLAPLD);
    assert(c == Constraint_WBSUPPRESS | c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_WBSUPPRESS => {
          wback = false
      },
      Constraint_UNKNOWN => {
          wb_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
if ((memop == MemOp_STORE & wback) & (t == n | t2 == n)) & n != 31 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_WBOVERLAPST);
    assert(c == Constraint_NONE | c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_NONE => {
          rt_unknown = false
      },
      Constraint_UNKNOWN => {
          rt_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
if memop == MemOp_LOAD & t == t2 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_LDPOVERLAP);
    assert(c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_UNKNOWN => {
          rt_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
assert(constraint('datasize in {32, 64}));
execute_aarch64_instrs_memory_pair_general_post_idx(datasize, memop, n, nontemporal, offset, postindex, rt_unknown, is_signed, t, t2, tagchecked, wb_unknown, wback)

Memory pair general pre-index

313029282726252423222120191817161514131211109876543210
0110100111imm7Rt2RnRt
opcL

0110100111xxxxxxxxxxxxxxxxxxxxxx

Decode Sail

wback : bool = true;
let postindex : bool = false;
let 'n = UInt(Rn);
let 't = UInt(Rt);
let 't2 = UInt(Rt2);
let nontemporal : bool = false;
let memop : MemOp = if L == 0b1 then MemOp_LOAD else MemOp_STORE;
if (L @ [opc[0]]) == 0b01 | opc == 0b11 then {
    throw(Error_Undefined())
};
let is_signed : bool = [opc[0]] != 0b0;
let 'scale = 2 + UInt([opc[1]]);
let 'datasize = (8 << scale);
let offset : bits(64) = LSL(SignExtend(imm7, 64), scale);
let tagchecked : bool = wback | n != 31;
rt_unknown : bool = false;
wb_unknown : bool = false;
if ((memop == MemOp_LOAD & wback) & (t == n | t2 == n)) & n != 31 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_WBOVERLAPLD);
    assert(c == Constraint_WBSUPPRESS | c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_WBSUPPRESS => {
          wback = false
      },
      Constraint_UNKNOWN => {
          wb_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
if ((memop == MemOp_STORE & wback) & (t == n | t2 == n)) & n != 31 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_WBOVERLAPST);
    assert(c == Constraint_NONE | c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_NONE => {
          rt_unknown = false
      },
      Constraint_UNKNOWN => {
          rt_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
if memop == MemOp_LOAD & t == t2 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_LDPOVERLAP);
    assert(c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_UNKNOWN => {
          rt_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
assert(constraint('datasize in {32, 64}));
execute_aarch64_instrs_memory_pair_general_post_idx(datasize, memop, n, nontemporal, offset, postindex, rt_unknown, is_signed, t, t2, tagchecked, wb_unknown, wback)

Memory pair general offset

313029282726252423222120191817161514131211109876543210
0110100101imm7Rt2RnRt
opcL

0110100101xxxxxxxxxxxxxxxxxxxxxx

Decode Sail

wback : bool = false;
let postindex : bool = false;
let 'n = UInt(Rn);
let 't = UInt(Rt);
let 't2 = UInt(Rt2);
let nontemporal : bool = false;
let memop : MemOp = if L == 0b1 then MemOp_LOAD else MemOp_STORE;
if (L @ [opc[0]]) == 0b01 | opc == 0b11 then {
    throw(Error_Undefined())
};
let is_signed : bool = [opc[0]] != 0b0;
let 'scale = 2 + UInt([opc[1]]);
let 'datasize = (8 << scale);
let offset : bits(64) = LSL(SignExtend(imm7, 64), scale);
let tagchecked : bool = wback | n != 31;
rt_unknown : bool = false;
wb_unknown : bool = false;
if ((memop == MemOp_LOAD & wback) & (t == n | t2 == n)) & n != 31 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_WBOVERLAPLD);
    assert(c == Constraint_WBSUPPRESS | c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_WBSUPPRESS => {
          wback = false
      },
      Constraint_UNKNOWN => {
          wb_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
if ((memop == MemOp_STORE & wback) & (t == n | t2 == n)) & n != 31 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_WBOVERLAPST);
    assert(c == Constraint_NONE | c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_NONE => {
          rt_unknown = false
      },
      Constraint_UNKNOWN => {
          rt_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
if memop == MemOp_LOAD & t == t2 then {
    let c : Constraint = ConstrainUnpredictable(Unpredictable_LDPOVERLAP);
    assert(c == Constraint_UNKNOWN | c == Constraint_UNDEF | c == Constraint_NOP);
    match c {
      Constraint_UNKNOWN => {
          rt_unknown = true
      },
      Constraint_UNDEF => {
          throw(Error_Undefined())
      },
      Constraint_NOP => {
          EndOfInstruction()
      },
      _ => ()
    }
};
assert(constraint('datasize in {32, 64}));
execute_aarch64_instrs_memory_pair_general_post_idx(datasize, memop, n, nontemporal, offset, postindex, rt_unknown, is_signed, t, t2, tagchecked, wb_unknown, wback)

Operation Sail

address : bits(64) = undefined;
data1 : bits('datasize) = undefined;
data2 : bits('datasize) = undefined;
let 'dbytes = DIV(datasize, 8);
let privileged : bool = PSTATE.EL != EL0;
let accdesc : AccessDescriptor = CreateAccDescGPR(memop, nontemporal, privileged, tagchecked);
if n == 31 then {
    CheckSPAlignment();
    address = SP_read()
} else {
    address = X_read(n, 64)
};
if not_bool(postindex) then {
    address = address + offset
};
match memop {
  MemOp_STORE => {
      if rt_unknown & t == n then {
          data1 = __UNKNOWN_bits(datasize)
      } else {
          data1 = X_read(t, datasize)
      };
      if rt_unknown & t2 == n then {
          data2 = __UNKNOWN_bits(datasize)
      } else {
          data2 = X_read(t2, datasize)
      };
      if HaveLSE2Ext() then {
          full_data : bits(2 * 'datasize) = undefined;
          if BigEndian(accdesc.acctype) then {
              full_data = data1 @ data2
          } else {
              full_data = data2 @ data1
          };
          let ispair : bool = true;
          Mem_set__1(address, 2 * dbytes, accdesc, ispair) = full_data
      } else {
          Mem_set(address + 0, dbytes, accdesc) = data1;
          Mem_set(address + dbytes, dbytes, accdesc) = data2
      }
  },
  MemOp_LOAD => {
      if HaveLSE2Ext() & not_bool(is_signed) then {
          let ispair : bool = true;
          let full_data : bits(2 * 'datasize) = Mem_read__1(address, 2 * dbytes, accdesc, ispair);
          if BigEndian(accdesc.acctype) then {
              data2 = full_data[datasize - 1 .. 0];
              data1 = full_data[2 * datasize - 1 .. datasize]
          } else {
              data1 = full_data[datasize - 1 .. 0];
              data2 = full_data[2 * datasize - 1 .. datasize]
          }
      } else {
          data1 = Mem_read(address + 0, dbytes, accdesc);
          data2 = Mem_read(address + dbytes, dbytes, accdesc)
      };
      if rt_unknown then {
          data1 = __UNKNOWN_bits(datasize);
          data2 = __UNKNOWN_bits(datasize)
      };
      if is_signed then {
          X_set(t, 64) = SignExtend(data1, 64);
          X_set(t2, 64) = SignExtend(data2, 64)
      } else {
          X_set(t, datasize) = data1;
          X_set(t2, datasize) = data2
      }
  },
  _ => ()
};
if wback then {
    if wb_unknown then {
        address = __UNKNOWN_bits(64)
    } else if postindex then {
        address = address + offset
    } else ();
    if n == 31 then {
        SP_set() = address
    } else {
        X_set(n, 64) = address
    }
};
if SPESampleInFlight then {
    SPESampleGeneralPurposeLoadStore()
};
()

Made from ScarletNX's Sail at 166ad3910f80. sail-arm's definitions are Arm's ASL in Sail (BSD 3-Clause Clear, license); ScarletNX's fixups are GPL-3.0-or-later.