]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: add new assembly format for BFPT and BFPF on loong64
authorGuoqi Chen <chenguoqi@loongson.cn>
Wed, 23 Apr 2025 02:30:39 +0000 (10:30 +0800)
committerabner chenc <chenguoqi@loongson.cn>
Fri, 25 Apr 2025 01:28:42 +0000 (18:28 -0700)
On loong64, BFPT and BFPF are mapped to the platform assembly as follows:

   Go asm syntax:
        BFPT   FCCx, offs21
        BFPF   FCCx, offs21
   Equivalent platform assembler syntax:
        bcnez  cj, offs21
        bceqz  cj, offs21

If the condition register is not specified, it defaults to FCC0.

Change-Id: I2cc3df62a9c55d4b5eb124789358983c6737319c
Reviewed-on: https://go-review.googlesource.com/c/go/+/667456
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
src/cmd/asm/internal/asm/testdata/loong64enc1.s
src/cmd/internal/obj/loong64/asm.go

index ad0ffa33d68c7ba0cb75b82465dac4894eac17e7..cfda9ba0b44306480c554aa4dbd32830f64770b7 100644 (file)
@@ -6,12 +6,16 @@
 
 TEXT asmtest(SB),DUPOK|NOSPLIT,$0
 lable1:
-       BFPT    1(PC)                   // 00050048
-       BFPT    lable1  // BFPT 2       //1ffdff4b
+       BFPT    1(PC)                           // 00050048
+       BFPT    lable1          // BFPT 2       // 1ffdff4b
+       BFPT    FCC0, lable1    // BFPT FCC0, 2 // 1ff9ff4b
+       BFPT    FCC7, lable1    // BFPT FCC7, 2 // fff5ff4b
 
 lable2:
-       BFPF    1(PC)                   // 00040048
-       BFPF    lable2  // BFPF 4       // 1ffcff4b
+       BFPF    1(PC)                           // 00040048
+       BFPF    lable2          // BFPF 6       // 1ffcff4b
+       BFPF    FCC0, lable2    // BFPF FCC0, 6 // 1ff8ff4b
+       BFPF    FCC7, lable2    // BFPF FCC7, 6 // fff4ff4b
 
        // relocation in play so the assembled offset should be 0
        JMP     foo(SB)                 // 00000050
index 1254695be8c806219444f7ceb3fe510d3679a8cc..7fdba0c6c2837950d203ee801ecc2b0346741066 100644 (file)
@@ -308,7 +308,8 @@ var optab = []Optab{
        {ABEQ, C_REG, C_REG, C_NONE, C_BRAN, C_NONE, 6, 4, 0, 0},
        {ABEQ, C_REG, C_NONE, C_NONE, C_BRAN, C_NONE, 6, 4, 0, 0},
        {ABLEZ, C_REG, C_NONE, C_NONE, C_BRAN, C_NONE, 6, 4, 0, 0},
-       {ABFPT, C_NONE, C_NONE, C_NONE, C_BRAN, C_NONE, 6, 4, 0, NOTUSETMP},
+       {ABFPT, C_NONE, C_NONE, C_NONE, C_BRAN, C_NONE, 6, 4, 0, 0},
+       {ABFPT, C_FCCREG, C_NONE, C_NONE, C_BRAN, C_NONE, 6, 4, 0, 0},
 
        {AJMP, C_NONE, C_NONE, C_NONE, C_BRAN, C_NONE, 11, 4, 0, 0}, // b
        {AJAL, C_NONE, C_NONE, C_NONE, C_BRAN, C_NONE, 11, 4, 0, 0}, // bl
@@ -1985,7 +1986,9 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
                        width = 21
                        // FCC0 is the implicit source operand, now that we
                        // don't register-allocate from the FCC bank.
-                       rj = REG_FCC0
+                       if rj == 0 {
+                               rj = REG_FCC0
+                       }
                case ABEQ, ABNE:
                        if rd == 0 || rd == REGZERO || rj == REGZERO {
                                // BEQZ/BNEZ can be encoded with 21-bit offsets.