From 69f1290fcb8593c2e7ee6262e363f1a6d9c1a436 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 14 Nov 2023 14:45:21 -0600 Subject: [PATCH] cmd/internal/obj/ppc64: add new constant optab classifications Make C_S32CON, C_U32CON, and C_32CON distinct classifiers to allow more specific matching of 32 bit constants. C_U31CON is added to support C_S32CON. Likewise, add C_16CON which is the union of C_S16CON and C_U16CON classification. This wil allow simplifying MOVD/MOVW optab entries in a future patch. Change-Id: I193acc0ded8f3edd91d306e39c3e7e55a9811e04 Reviewed-on: https://go-review.googlesource.com/c/go/+/562346 Reviewed-by: Lynn Boger Reviewed-by: Michael Knyszek Reviewed-by: David Chase Reviewed-by: Than McIntosh Run-TryBot: Paul Murphy TryBot-Result: Gopher Robot --- src/cmd/internal/obj/ppc64/a.out.go | 8 ++++---- src/cmd/internal/obj/ppc64/anames9.go | 4 ++++ src/cmd/internal/obj/ppc64/asm9.go | 17 ++++++++++++----- src/cmd/internal/obj/ppc64/asm_test.go | 4 +++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/cmd/internal/obj/ppc64/a.out.go b/src/cmd/internal/obj/ppc64/a.out.go index 44c6b09d66..c18556f1f3 100644 --- a/src/cmd/internal/obj/ppc64/a.out.go +++ b/src/cmd/internal/obj/ppc64/a.out.go @@ -422,6 +422,10 @@ const ( C_U15CON /* 15 bit unsigned constant */ C_S16CON /* 16 bit signed constant */ C_U16CON /* 16 bit unsigned constant */ + C_16CON /* Any constant which fits into 16 bits. Can be signed or unsigned */ + C_U31CON /* 31 bit unsigned constant */ + C_S32CON /* 32 bit signed constant */ + C_U32CON /* 32 bit unsigned constant */ C_32CON /* Any constant which fits into 32 bits. Can be signed or unsigned */ C_S34CON /* 34 bit signed constant */ C_64CON /* Any constant which fits into 64 bits. Can be signed or unsigned */ @@ -451,10 +455,6 @@ const ( C_ADDCON = C_S16CON C_ANDCON = C_U16CON C_LCON = C_32CON - - /* Aliased names which may be generated by ppc64map for the optab. */ - C_S32CON = C_32CON - C_U32CON = C_32CON ) const ( diff --git a/src/cmd/internal/obj/ppc64/anames9.go b/src/cmd/internal/obj/ppc64/anames9.go index 824bc2ab68..81f73dcea6 100644 --- a/src/cmd/internal/obj/ppc64/anames9.go +++ b/src/cmd/internal/obj/ppc64/anames9.go @@ -27,6 +27,10 @@ var cnames9 = []string{ "U15CON", "S16CON", "U16CON", + "16CON", + "U31CON", + "S32CON", + "U32CON", "32CON", "S34CON", "64CON", diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 541d9fdbbd..2455d6ad2e 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -1016,7 +1016,7 @@ func (c *ctxt9) aclass(a *obj.Addr) int { case sbits <= 16: return C_U16CON case sbits <= 31: - return C_U32CON + return C_U31CON case sbits <= 32: return C_U32CON case sbits <= 33: @@ -1144,13 +1144,20 @@ func cmp(a int, b int) bool { return cmp(C_U5CON, b) case C_U15CON: return cmp(C_U8CON, b) - case C_U16CON: - return cmp(C_U15CON, b) - case C_S16CON: return cmp(C_U15CON, b) - case C_32CON: + case C_U16CON: + return cmp(C_U15CON, b) + case C_16CON: return cmp(C_S16CON, b) || cmp(C_U16CON, b) + case C_U31CON: + return cmp(C_U16CON, b) + case C_U32CON: + return cmp(C_U31CON, b) + case C_S32CON: + return cmp(C_U31CON, b) || cmp(C_S16CON, b) + case C_32CON: + return cmp(C_S32CON, b) || cmp(C_U32CON, b) case C_S34CON: return cmp(C_32CON, b) case C_64CON: diff --git a/src/cmd/internal/obj/ppc64/asm_test.go b/src/cmd/internal/obj/ppc64/asm_test.go index 186112b88f..0ef457e8d0 100644 --- a/src/cmd/internal/obj/ppc64/asm_test.go +++ b/src/cmd/internal/obj/ppc64/asm_test.go @@ -516,11 +516,13 @@ func TestAddrClassifier(t *testing.T) { {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 32}, C_U8CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 14}, C_U15CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 15}, C_U16CON}, - {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 + 1<<16}, C_U32CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 + 1<<16}, C_U31CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 31}, C_U32CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 32}, C_S34CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 1 << 33}, C_64CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -1}, C_S16CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -0x10001}, C_S32CON}, + {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: 0x10001}, C_U31CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -(1 << 33)}, C_S34CON}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -(1 << 34)}, C_64CON}, -- 2.48.1