[otbn] Add a test for %lo(..) and %hi(..) support
It turns out that this works "for free" for instructions like
ADDI (which otbn-as can generate with .insn lines). Add a test to make
sure nothing comes unstuck.
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otbn/dv/otbnsim/test/simple/relocs/hilo.exp b/hw/ip/otbn/dv/otbnsim/test/simple/relocs/hilo.exp
new file mode 100644
index 0000000..eba3151
--- /dev/null
+++ b/hw/ip/otbn/dv/otbnsim/test/simple/relocs/hilo.exp
@@ -0,0 +1,9 @@
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+x2 = 0
+x3 = 4
+x4 = 0x1234
+x5 = 0x5678
+x6 = 0
diff --git a/hw/ip/otbn/dv/otbnsim/test/simple/relocs/hilo.s b/hw/ip/otbn/dv/otbnsim/test/simple/relocs/hilo.s
new file mode 100644
index 0000000..1431aa6
--- /dev/null
+++ b/hw/ip/otbn/dv/otbnsim/test/simple/relocs/hilo.s
@@ -0,0 +1,26 @@
+/* Copyright lowRISC contributors. */
+/* Licensed under the Apache License, Version 2.0, see LICENSE for details. */
+/* SPDX-License-Identifier: Apache-2.0 */
+
+/*
+ Code that checks we correctly handle the %lo(...) and %hi(...) relocs
+*/
+
+.data
+foo:
+ .word 0x1234
+bar:
+ .word 0x5678
+
+.text
+ addi x2, x0, %lo(foo)
+ addi x3, x0, %lo(bar)
+ lw x4, 0(x2)
+ lw x5, 0(x3)
+
+ /* No matter what addresses foo and bar have, we can be pretty
+ certain they're representable in 12 bits (if not, they wouldn't
+ fit in DMEM). */
+ lui x6, %hi(bar)
+
+ ecall