Commit cbcf4592 authored by Kunshan Wang's avatar Kunshan Wang

Fixed tagref64 operations on aarch64

Now it no longer assume the higher 16 bits of a ref are either all 0s or
all 1s.  The layout of bits of tabref64 is changed, but is not visible
to the client.
parent 72dcd8b1
...@@ -186,16 +186,16 @@ object OpHelper { ...@@ -186,16 +186,16 @@ object OpHelper {
* NOTE: All objects are 8-byte aligned. The current Mu spec's design only * NOTE: All objects are 8-byte aligned. The current Mu spec's design only
* allows 48-bit effective address. which x86_64 currently implements. * allows 48-bit effective address. which x86_64 currently implements.
* *
* ref: ssss ssss ssss ssss srrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr r000 * ref: 0000 0000 0000 0000 rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr r000
* where s is either 1 or 0
* *
* tag: aaaaab * tag: abbbbc
* *
* tagref64: s111 1111 1111 aaaa arrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rb10 * tagref64: a111 1111 1111 bbbb rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rc10
*/ */
def refToTr64(opnd: Long, tag: Long): Long = { def refToTr64(opnd: Long, tag: Long): Long = {
(0x7ff0000000000002L | (opnd & 0x7ffffffffff8L) | ((opnd & 0x800000000000L) << 16) | (0x7ff0000000000002L | (opnd & 0xfffffffffff8L) |
((tag & 0x3eL) << 46) | ((tag & 0x20L) << (63 - 5)) |
((tag & 0x1eL) << (48 - 1)) |
((tag & 0x1) << 2)) ((tag & 0x1) << 2))
} }
...@@ -222,19 +222,18 @@ object OpHelper { ...@@ -222,19 +222,18 @@ object OpHelper {
* ref: ssss ssss ssss ssss srrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr r000 * ref: ssss ssss ssss ssss srrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr rrrr r000
*/ */
def tr64ToRef(opnd: Long): Long = { def tr64ToRef(opnd: Long): Long = {
((opnd & 0x7ffffffffff8L) | (opnd & 0xfffffffffff8L)
((opnd & 0x8000000000000000L) >> 16))
} }
/** /**
* Assume the tagref64 opnd represents a ref and a tag, and extract the tag. * Assume the tagref64 opnd represents a ref and a tag, and extract the tag.
* *
* tagref64: ???? ???? ???? aaaa a??? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ?b?? * tagref64: a??? ???? ???? bbbb ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ?c??
* *
* tag: aaaaab * tag: aaaaab
*/ */
def tr64ToTag(opnd: Long): Long = { def tr64ToTag(opnd: Long): Long = {
(((opnd & 0x000f800000000000L) >> 46) | ((opnd & 0x4) >> 2)) (((opnd & 0x8000000000000000L) >>> (63 - 5) | (opnd & 0x000f000000000000L) >>> (48 - 1)) | ((opnd & 0x4) >>> 2))
} }
} }
......
...@@ -48,8 +48,8 @@ class UvmTagRef64OperationSpec extends UvmTestBase { ...@@ -48,8 +48,8 @@ class UvmTagRef64OperationSpec extends UvmTestBase {
it should "encode ref and tag" in { it should "encode ref and tag" in {
OpHelper.refToTr64(0x000000000000L, 0x00L) shouldBe 0x7ff0000000000002L OpHelper.refToTr64(0x000000000000L, 0x00L) shouldBe 0x7ff0000000000002L
OpHelper.refToTr64(0x7ffffffffff8L, 0x00L) shouldBe 0x7ff07ffffffffffaL OpHelper.refToTr64(0x7ffffffffff8L, 0x00L) shouldBe 0x7ff07ffffffffffaL
OpHelper.refToTr64(0xfffffffffffffff8L, 0x00L) shouldBe 0xfff07ffffffffffaL OpHelper.refToTr64(0xfffffffffff8L, 0x00L) shouldBe 0x7ff0fffffffffffaL
OpHelper.refToTr64(0x000000000000L, 0x3fL) shouldBe 0x7fff800000000006L OpHelper.refToTr64(0x000000000000L, 0x3fL) shouldBe 0xffff000000000006L
} }
it should "decode integer" in { it should "decode integer" in {
...@@ -68,10 +68,12 @@ class UvmTagRef64OperationSpec extends UvmTestBase { ...@@ -68,10 +68,12 @@ class UvmTagRef64OperationSpec extends UvmTestBase {
it should "decodde ref and tag" in { it should "decodde ref and tag" in {
OpHelper.tr64ToRef(0x7ff0555555555552L) shouldBe 0x555555555550L OpHelper.tr64ToRef(0x7ff0555555555552L) shouldBe 0x555555555550L
OpHelper.tr64ToRef(0xfff02aaaaaaaaaaaL) shouldBe 0xffffaaaaaaaaaaa8L OpHelper.tr64ToRef(0x7ff0aaaaaaaaaaaaL) shouldBe 0xaaaaaaaaaaa8L
OpHelper.tr64ToRef(0x7ff0fffffffffffaL) shouldBe 0xfffffffffff8L
OpHelper.tr64ToTag(0x7ff0555555555552L) shouldBe 0 OpHelper.tr64ToTag(0x7ff0555555555552L) shouldBe 0
OpHelper.tr64ToTag(0x7fff800000000006L) shouldBe 0x3f OpHelper.tr64ToTag(0xffff000000000006L) shouldBe 0x3f
OpHelper.tr64ToTag(0x7ffa800000000002L) shouldBe 0x2a OpHelper.tr64ToTag(0xfff0000000000002L) shouldBe 0x20
OpHelper.tr64ToTag(0x7ff5000000000006L) shouldBe 0x15 OpHelper.tr64ToTag(0x7fff000000000002L) shouldBe 0x1e
OpHelper.tr64ToTag(0x7ff0000000000006L) shouldBe 0x01
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment