This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add zbkb feature for zext.h Instruction
Needs ReviewPublic

Authored by Miss_Grape on Mar 22 2022, 1:12 AM.

Details

Diff Detail

Event Timeline

Miss_Grape created this revision.Mar 22 2022, 1:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 1:12 AM
Miss_Grape requested review of this revision.Mar 22 2022, 1:12 AM
benshi001 added inline comments.Mar 22 2022, 7:00 AM
llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
654

We need not such aliases, since there is real zext.h instruction.

benshi001 added inline comments.Mar 22 2022, 7:13 AM
llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
654

We need not two zext.h, maybe just one is OK, when ZBB is invalid.

Looks like a test is missing?

The correct fix is to change the predicate here to include Zbkb

let Predicates = [HasStdExtZbbOrZbp, IsRV32] in {                                
def ZEXT_H_RV32 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP, "zext.h">,         
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV32]                                    
                                                                                 
let Predicates = [HasStdExtZbbOrZbp, IsRV64] in {                                
def ZEXT_H_RV64 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP_32, "zext.h">,      
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV64]

We should also verify the behavior of binutils.

Miss_Grape added inline comments.Mar 22 2022, 6:46 PM
llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
654

real MI is PACK and PACKW,so just need Predicates = HasStdExtZbpOrZbkb

The correct fix is to change the predicate here to include Zbkb

let Predicates = [HasStdExtZbbOrZbp, IsRV32] in {                                
def ZEXT_H_RV32 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP, "zext.h">,         
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV32]                                    
                                                                                 
let Predicates = [HasStdExtZbbOrZbp, IsRV64] in {                                
def ZEXT_H_RV64 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP_32, "zext.h">,      
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV64]

Can you send me the Bitmap manual you read, I read the riscv-crypto-spec-scalar-v1.0.1.pdf , and zext.h does not belong to zbkb
zbkb Instruction:

craig.topper added a comment.EditedMar 31 2022, 8:20 AM

The correct fix is to change the predicate here to include Zbkb

let Predicates = [HasStdExtZbbOrZbp, IsRV32] in {                                
def ZEXT_H_RV32 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP, "zext.h">,         
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV32]                                    
                                                                                 
let Predicates = [HasStdExtZbbOrZbp, IsRV64] in {                                
def ZEXT_H_RV64 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP_32, "zext.h">,      
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV64]

Can you send me the Bitmap manual you read, I read the riscv-crypto-spec-scalar-v1.0.1.pdf , and zext.h does not belong to zbkb
zbkb Instruction:

The zext.h encoding is a subset of the pack encodings. We need to have consistent behavior in when we use the two instruction representations. Otherwise disassembling with Zbb and Zbkb both enabled becomes ambiguous.

Miss_Grape retitled this revision from [RISCV] Add alias to pack/packw to [RISCV] Add zbkb feature for zext.h Instruction.

The correct fix is to change the predicate here to include Zbkb

let Predicates = [HasStdExtZbbOrZbp, IsRV32] in {                                
def ZEXT_H_RV32 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP, "zext.h">,         
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV32]                                    
                                                                                 
let Predicates = [HasStdExtZbbOrZbp, IsRV64] in {                                
def ZEXT_H_RV64 : RVBUnary<0b0000100, 0b00000, 0b100, OPC_OP_32, "zext.h">,      
                  Sched<[WriteIALU, ReadIALU]>;                                  
} // Predicates = [HasStdExtZbbOrZbp, IsRV64]

Can you send me the Bitmap manual you read, I read the riscv-crypto-spec-scalar-v1.0.1.pdf , and zext.h does not belong to zbkb
zbkb Instruction:

The zext.h encoding is a subset of the pack encodings. We need to have consistent behavior in when we use the two instruction representations. Otherwise disassembling with Zbb and Zbkb both enabled becomes ambiguous.

Fixed