72132 Commits

Author SHA1 Message Date
Fangrui Song
8afd831b45 ms inline asm: recognize case-insensitive JMP and CALL as TargetLowering::C_Address
In a `__asm` block, a symbol reference is usually a memory constraint
(indirect TargetLowering::C_Memory) [LOOP]. CALL and JUMP instructions are special
that `__asm call k` can be an address constraint, if `k` is a function.

Clang always gives us indirect TargetLowering::C_Memory and need to convert it
to direct TargetLowering::C_Address. D133914 implements this conversion, but
does not consider JMP or case-insensitive CALL. This patch implements the missing
cases, so that `__asm jmp k` (`jmp ${0:P}`) will correctly lower to `jmp _k`
instead of `jmp dword ptr [_k]`.

(`__asm call k` lowered to `call dword ptr ${0:P}` and is fixed by D149695 to
lower to `call ${0:P}` instead.)

[LOOP]: Some instructions like LOOP{,E,NE} and Jcc always use an address
constraint (`loop _k` instead of `loop dword ptr [_k]`).

After this patch and D149579, all the following cases will be correct.
```
int k(int);
int (*kptr)(int);
...
__asm call k; // correct without this patch
__asm CALL k; // correct, but needs this patch to be compatible with D149579
__asm jmp k;  // correct, but needs this patch to be compatible with D149579
__asm call kptr; // will be fixed by D149579.  "Broken case" in clang/test/CodeGen/ms-inline-asm-functions.c
__asm jmp kptr;  // will be fixed by this patch and D149579
```

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D149920
2023-05-05 15:32:32 -07:00
Philip Reames
c501aa8843 [RISCV][TTI] Model shuffle mask materialization with correct index type
We were modeling these as if the index type was always e8, but the actual
lowering uses the data type width if legal.  We also weren't accounting for
i64 on xlen32 correctly.

Noticed via inspection while working on the shuffle/buildvec lowering.  Note
that this costing is also wrong in a more major way - we don't actually use
a constant pool load in many cases.  But that's a separate issue.
2023-05-05 12:26:21 -07:00
Simon Pilgrim
051918c71e [DAG] expandIntMINMAX - add umax(x,1) --> sub(x,cmpeq(x,0)) fold
Move the fold from X86 to generic expansion

(We also have several existing expansions that are missing freezes on repeated operands - I've added a TODO for now).
2023-05-05 19:27:52 +01:00
Michael Maitland
f9fa8a5997 [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td
Based on the following description from Andrew W.

Instructions not mentioned here behave the same as integer ALU ops
rev8 only executes in the late-A and late-B ALUs
shNadd[.uw] only execute on the early-B and late-B ALUs
clz[w], ctz[w], and orc.b and all rotates only execute in the late-B ALU
pcnt[w] looks exactly like integer multiply
This patch does not account for early/late ALU in the model. It is coded based
on the pipes only.

Co-Authored-By: topperc <craig.topper@sifive.com>

Differential Revision: https://reviews.llvm.org/D149497
2023-05-05 10:16:35 -07:00
Craig Topper
913b95fb80 [RISCV] Add X1 as implicit def of cm.jalt.
This instruction updates the RA register.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D149933
2023-05-05 10:08:47 -07:00
Craig Topper
7b3b178c82 [RISCV] Add DecoderNamespace to Zcmt instructions.
The Zcmt instructions overlap encoding space with some C extension
instructions. Isolate to a separate namespace.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D149891
2023-05-05 10:08:43 -07:00
Michael Maitland
839469436a [RISCV] Add sifive-x280 processor with all of its extensions
Add sifive-x280 processor that uses the SiFive7 scheduler model.

Differential Revision: https://reviews.llvm.org/D149710
2023-05-05 10:02:28 -07:00
David Green
6e7840dd42 [AArch64] Extend fp64 top zeroing peephole to all instructions
D147235 added a fold to remove instructions that zero the upper half of a
register if the instruction already implicitly zeros the register. As far as I
can tell this applies to all instructions that define a FPR64 register in
AArch64. This patch switches to a check for the register class. The full list
of instructions is:
  BSPv8i8
  FMOVD0
  ABSv1i64
  ABSv2i32
  ABSv4i16
  ABSv8i8
  ADDHNv2i64_v2i32
  ADDHNv4i32_v4i16
  ADDHNv8i16_v8i8
  ADDPv2i32
  ADDPv2i64p
  ADDPv4i16
  ADDPv8i8
  ADDv1i64
  ADDv2i32
  ADDv4i16
  ADDv8i8
  ANDv8i8
  BF16DOTlanev4bf16
  BFDOTv4bf16
  BICv2i32
  BICv4i16
  BICv8i8
  BIFv8i8
  BITv8i8
  BSLv8i8
  CLASTA_VPZ_D
  CLASTB_VPZ_D
  CLSv2i32
  CLSv4i16
  CLSv8i8
  CLZv2i32
  CLZv4i16
  CLZv8i8
  CMEQv1i64
  CMEQv1i64rz
  CMEQv2i32
  CMEQv2i32rz
  CMEQv4i16
  CMEQv4i16rz
  CMEQv8i8
  CMEQv8i8rz
  CMGEv1i64
  CMGEv1i64rz
  CMGEv2i32
  CMGEv2i32rz
  CMGEv4i16
  CMGEv4i16rz
  CMGEv8i8
  CMGEv8i8rz
  CMGTv1i64
  CMGTv1i64rz
  CMGTv2i32
  CMGTv2i32rz
  CMGTv4i16
  CMGTv4i16rz
  CMGTv8i8
  CMGTv8i8rz
  CMHIv1i64
  CMHIv2i32
  CMHIv4i16
  CMHIv8i8
  CMHSv1i64
  CMHSv2i32
  CMHSv4i16
  CMHSv8i8
  CMLEv1i64rz
  CMLEv2i32rz
  CMLEv4i16rz
  CMLEv8i8rz
  CMLTv1i64rz
  CMLTv2i32rz
  CMLTv4i16rz
  CMLTv8i8rz
  CMTSTv1i64
  CMTSTv2i32
  CMTSTv4i16
  CMTSTv8i8
  CNTv8i8
  DUPi64
  DUPv2i32gpr
  DUPv2i32lane
  DUPv4i16gpr
  DUPv4i16lane
  DUPv8i8gpr
  DUPv8i8lane
  EORv8i8
  EXTv8i8
  FABD64
  FABDv2f32
  FABDv4f16
  FABSDr
  FABSv2f32
  FABSv4f16
  FACGE64
  FACGEv2f32
  FACGEv4f16
  FACGT64
  FACGTv2f32
  FACGTv4f16
  FADDDrr
  FADDPv2f32
  FADDPv2i64p
  FADDPv4f16
  FADDv2f32
  FADDv4f16
  FCADDv2f32
  FCADDv4f16
  FCMEQ64
  FCMEQv1i64rz
  FCMEQv2f32
  FCMEQv2i32rz
  FCMEQv4f16
  FCMEQv4i16rz
  FCMGE64
  FCMGEv1i64rz
  FCMGEv2f32
  FCMGEv2i32rz
  FCMGEv4f16
  FCMGEv4i16rz
  FCMGT64
  FCMGTv1i64rz
  FCMGTv2f32
  FCMGTv2i32rz
  FCMGTv4f16
  FCMGTv4i16rz
  FCMLAv2f32
  FCMLAv4f16
  FCMLAv4f16_indexed
  FCMLEv1i64rz
  FCMLEv2i32rz
  FCMLEv4i16rz
  FCMLTv1i64rz
  FCMLTv2i32rz
  FCMLTv4i16rz
  FCSELDrrr
  FCVTASv1i64
  FCVTASv2f32
  FCVTASv4f16
  FCVTAUv1i64
  FCVTAUv2f32
  FCVTAUv4f16
  FCVTDHr
  FCVTDSr
  FCVTMSv1i64
  FCVTMSv2f32
  FCVTMSv4f16
  FCVTMUv1i64
  FCVTMUv2f32
  FCVTMUv4f16
  FCVTNSv1i64
  FCVTNSv2f32
  FCVTNSv4f16
  FCVTNUv1i64
  FCVTNUv2f32
  FCVTNUv4f16
  FCVTNv2i32
  FCVTNv4i16
  FCVTPSv1i64
  FCVTPSv2f32
  FCVTPSv4f16
  FCVTPUv1i64
  FCVTPUv2f32
  FCVTPUv4f16
  FCVTXNv2f32
  FCVTZSd
  FCVTZSv1i64
  FCVTZSv2f32
  FCVTZSv2i32_shift
  FCVTZSv4f16
  FCVTZSv4i16_shift
  FCVTZUd
  FCVTZUv1i64
  FCVTZUv2f32
  FCVTZUv2i32_shift
  FCVTZUv4f16
  FCVTZUv4i16_shift
  FDIVDrr
  FDIVv2f32
  FDIVv4f16
  FMADDDrrr
  FMAXDrr
  FMAXNMDrr
  FMAXNMPv2f32
  FMAXNMPv2i64p
  FMAXNMPv4f16
  FMAXNMv2f32
  FMAXNMv4f16
  FMAXPv2f32
  FMAXPv2i64p
  FMAXPv4f16
  FMAXv2f32
  FMAXv4f16
  FMINDrr
  FMINNMDrr
  FMINNMPv2f32
  FMINNMPv2i64p
  FMINNMPv4f16
  FMINNMv2f32
  FMINNMv4f16
  FMINPv2f32
  FMINPv2i64p
  FMINPv4f16
  FMINv2f32
  FMINv4f16
  FMLAL2lanev4f16
  FMLAL2v4f16
  FMLALlanev4f16
  FMLALv4f16
  FMLAv1i64_indexed
  FMLAv2f32
  FMLAv2i32_indexed
  FMLAv4f16
  FMLAv4i16_indexed
  FMLSL2lanev4f16
  FMLSL2v4f16
  FMLSLlanev4f16
  FMLSLv4f16
  FMLSv1i64_indexed
  FMLSv2f32
  FMLSv2i32_indexed
  FMLSv4f16
  FMLSv4i16_indexed
  FMOVDi
  FMOVDr
  FMOVXDr
  FMOVv2f32_ns
  FMOVv4f16_ns
  FMSUBDrrr
  FMULDrr
  FMULX64
  FMULXv1i64_indexed
  FMULXv2f32
  FMULXv2i32_indexed
  FMULXv4f16
  FMULXv4i16_indexed
  FMULv1i64_indexed
  FMULv2f32
  FMULv2i32_indexed
  FMULv4f16
  FMULv4i16_indexed
  FNEGDr
  FNEGv2f32
  FNEGv4f16
  FNMADDDrrr
  FNMSUBDrrr
  FNMULDrr
  FRECPEv1i64
  FRECPEv2f32
  FRECPEv4f16
  FRECPS64
  FRECPSv2f32
  FRECPSv4f16
  FRECPXv1i64
  FRINT32XDr
  FRINT32Xv2f32
  FRINT32ZDr
  FRINT32Zv2f32
  FRINT64XDr
  FRINT64Xv2f32
  FRINT64ZDr
  FRINT64Zv2f32
  FRINTADr
  FRINTAv2f32
  FRINTAv4f16
  FRINTIDr
  FRINTIv2f32
  FRINTIv4f16
  FRINTMDr
  FRINTMv2f32
  FRINTMv4f16
  FRINTNDr
  FRINTNv2f32
  FRINTNv4f16
  FRINTPDr
  FRINTPv2f32
  FRINTPv4f16
  FRINTXDr
  FRINTXv2f32
  FRINTXv4f16
  FRINTZDr
  FRINTZv2f32
  FRINTZv4f16
  FRSQRTEv1i64
  FRSQRTEv2f32
  FRSQRTEv4f16
  FRSQRTS64
  FRSQRTSv2f32
  FRSQRTSv4f16
  FSQRTDr
  FSQRTv2f32
  FSQRTv4f16
  FSUBDrr
  FSUBv2f32
  FSUBv4f16
  LASTA_VPZ_D
  LASTB_VPZ_D
  LD1Onev1d
  LD1Onev2s
  LD1Onev4h
  LD1Onev8b
  LD1Rv1d
  LD1Rv2s
  LD1Rv4h
  LD1Rv8b
  LDAPURdi
  LDNPDi
  LDPDi
  LDRDl
  LDRDroW
  LDRDroX
  LDRDui
  LDURDi
  MLAv2i32
  MLAv2i32_indexed
  MLAv4i16
  MLAv4i16_indexed
  MLAv8i8
  MLSv2i32
  MLSv2i32_indexed
  MLSv4i16
  MLSv4i16_indexed
  MLSv8i8
  MOVID
  MOVIv2i32
  MOVIv2s_msl
  MOVIv4i16
  MOVIv8b_ns
  MULv2i32
  MULv2i32_indexed
  MULv4i16
  MULv4i16_indexed
  MULv8i8
  MVNIv2i32
  MVNIv2s_msl
  MVNIv4i16
  NEGv1i64
  NEGv2i32
  NEGv4i16
  NEGv8i8
  NOTv8i8
  ORNv8i8
  ORRv2i32
  ORRv4i16
  ORRv8i8
  PMULv8i8
  RADDHNv2i64_v2i32
  RADDHNv4i32_v4i16
  RADDHNv8i16_v8i8
  RBITv8i8
  REV16v8i8
  REV32v4i16
  REV32v8i8
  REV64v2i32
  REV64v4i16
  REV64v8i8
  RSHRNv2i32_shift
  RSHRNv4i16_shift
  RSHRNv8i8_shift
  RSUBHNv2i64_v2i32
  RSUBHNv4i32_v4i16
  RSUBHNv8i16_v8i8
  SABAv2i32
  SABAv4i16
  SABAv8i8
  SABDv2i32
  SABDv4i16
  SABDv8i8
  SADALPv2i32_v1i64
  SADALPv4i16_v2i32
  SADALPv8i8_v4i16
  SADDLPv2i32_v1i64
  SADDLPv4i16_v2i32
  SADDLPv8i8_v4i16
  SADDLVv4i32v
  SCVTFSWDri
  SCVTFSXDri
  SCVTFUWDri
  SCVTFUXDri
  SCVTFd
  SCVTFv1i64
  SCVTFv2f32
  SCVTFv2i32_shift
  SCVTFv4f16
  SCVTFv4i16_shift
  SDOTlanev8i8
  SDOTv8i8
  SHADDv2i32
  SHADDv4i16
  SHADDv8i8
  SHLd
  SHLv2i32_shift
  SHLv4i16_shift
  SHLv8i8_shift
  SHRNv2i32_shift
  SHRNv4i16_shift
  SHRNv8i8_shift
  SHSUBv2i32
  SHSUBv4i16
  SHSUBv8i8
  SLId
  SLIv2i32_shift
  SLIv4i16_shift
  SLIv8i8_shift
  SMAXPv2i32
  SMAXPv4i16
  SMAXPv8i8
  SMAXv2i32
  SMAXv4i16
  SMAXv8i8
  SMINPv2i32
  SMINPv4i16
  SMINPv8i8
  SMINv2i32
  SMINv4i16
  SMINv8i8
  SQABSv1i64
  SQABSv2i32
  SQABSv4i16
  SQABSv8i8
  SQADDv1i64
  SQADDv2i32
  SQADDv4i16
  SQADDv8i8
  SQDMLALi32
  SQDMLALv1i64_indexed
  SQDMLSLi32
  SQDMLSLv1i64_indexed
  SQDMULHv2i32
  SQDMULHv2i32_indexed
  SQDMULHv4i16
  SQDMULHv4i16_indexed
  SQDMULLi32
  SQDMULLv1i64_indexed
  SQNEGv1i64
  SQNEGv2i32
  SQNEGv4i16
  SQNEGv8i8
  SQRDMLAHv2i32
  SQRDMLAHv2i32_indexed
  SQRDMLAHv4i16
  SQRDMLAHv4i16_indexed
  SQRDMLSHv2i32
  SQRDMLSHv2i32_indexed
  SQRDMLSHv4i16
  SQRDMLSHv4i16_indexed
  SQRDMULHv2i32
  SQRDMULHv2i32_indexed
  SQRDMULHv4i16
  SQRDMULHv4i16_indexed
  SQRSHLv1i64
  SQRSHLv2i32
  SQRSHLv4i16
  SQRSHLv8i8
  SQRSHRNv2i32_shift
  SQRSHRNv4i16_shift
  SQRSHRNv8i8_shift
  SQRSHRUNv2i32_shift
  SQRSHRUNv4i16_shift
  SQRSHRUNv8i8_shift
  SQSHLUd
  SQSHLUv2i32_shift
  SQSHLUv4i16_shift
  SQSHLUv8i8_shift
  SQSHLd
  SQSHLv1i64
  SQSHLv2i32
  SQSHLv2i32_shift
  SQSHLv4i16
  SQSHLv4i16_shift
  SQSHLv8i8
  SQSHLv8i8_shift
  SQSHRNv2i32_shift
  SQSHRNv4i16_shift
  SQSHRNv8i8_shift
  SQSHRUNv2i32_shift
  SQSHRUNv4i16_shift
  SQSHRUNv8i8_shift
  SQSUBv1i64
  SQSUBv2i32
  SQSUBv4i16
  SQSUBv8i8
  SQXTNv2i32
  SQXTNv4i16
  SQXTNv8i8
  SQXTUNv2i32
  SQXTUNv4i16
  SQXTUNv8i8
  SRHADDv2i32
  SRHADDv4i16
  SRHADDv8i8
  SRId
  SRIv2i32_shift
  SRIv4i16_shift
  SRIv8i8_shift
  SRSHLv1i64
  SRSHLv2i32
  SRSHLv4i16
  SRSHLv8i8
  SRSHRd
  SRSHRv2i32_shift
  SRSHRv4i16_shift
  SRSHRv8i8_shift
  SRSRAd
  SRSRAv2i32_shift
  SRSRAv4i16_shift
  SRSRAv8i8_shift
  SSHLv1i64
  SSHLv2i32
  SSHLv4i16
  SSHLv8i8
  SSHRd
  SSHRv2i32_shift
  SSHRv4i16_shift
  SSHRv8i8_shift
  SSRAd
  SSRAv2i32_shift
  SSRAv4i16_shift
  SSRAv8i8_shift
  SUBHNv2i64_v2i32
  SUBHNv4i32_v4i16
  SUBHNv8i16_v8i8
  SUBv1i64
  SUBv2i32
  SUBv4i16
  SUBv8i8
  SUDOTlanev8i8
  SUQADDv1i64
  SUQADDv2i32
  SUQADDv4i16
  SUQADDv8i8
  TBLv8i8Four
  TBLv8i8One
  TBLv8i8Three
  TBLv8i8Two
  TBXv8i8Four
  TBXv8i8One
  TBXv8i8Three
  TBXv8i8Two
  TRN1v2i32
  TRN1v4i16
  TRN1v8i8
  TRN2v2i32
  TRN2v4i16
  TRN2v8i8
  UABAv2i32
  UABAv4i16
  UABAv8i8
  UABDv2i32
  UABDv4i16
  UABDv8i8
  UADALPv2i32_v1i64
  UADALPv4i16_v2i32
  UADALPv8i8_v4i16
  UADDLPv2i32_v1i64
  UADDLPv4i16_v2i32
  UADDLPv8i8_v4i16
  UADDLVv4i32v
  UCVTFSWDri
  UCVTFSXDri
  UCVTFUWDri
  UCVTFUXDri
  UCVTFd
  UCVTFv1i64
  UCVTFv2f32
  UCVTFv2i32_shift
  UCVTFv4f16
  UCVTFv4i16_shift
  UDOTlanev8i8
  UDOTv8i8
  UHADDv2i32
  UHADDv4i16
  UHADDv8i8
  UHSUBv2i32
  UHSUBv4i16
  UHSUBv8i8
  UMAXPv2i32
  UMAXPv4i16
  UMAXPv8i8
  UMAXv2i32
  UMAXv4i16
  UMAXv8i8
  UMINPv2i32
  UMINPv4i16
  UMINPv8i8
  UMINv2i32
  UMINv4i16
  UMINv8i8
  UQADDv1i64
  UQADDv2i32
  UQADDv4i16
  UQADDv8i8
  UQRSHLv1i64
  UQRSHLv2i32
  UQRSHLv4i16
  UQRSHLv8i8
  UQRSHRNv2i32_shift
  UQRSHRNv4i16_shift
  UQRSHRNv8i8_shift
  UQSHLd
  UQSHLv1i64
  UQSHLv2i32
  UQSHLv2i32_shift
  UQSHLv4i16
  UQSHLv4i16_shift
  UQSHLv8i8
  UQSHLv8i8_shift
  UQSHRNv2i32_shift
  UQSHRNv4i16_shift
  UQSHRNv8i8_shift
  UQSUBv1i64
  UQSUBv2i32
  UQSUBv4i16
  UQSUBv8i8
  UQXTNv2i32
  UQXTNv4i16
  UQXTNv8i8
  URECPEv2i32
  URHADDv2i32
  URHADDv4i16
  URHADDv8i8
  URSHLv1i64
  URSHLv2i32
  URSHLv4i16
  URSHLv8i8
  URSHRd
  URSHRv2i32_shift
  URSHRv4i16_shift
  URSHRv8i8_shift
  URSQRTEv2i32
  URSRAd
  URSRAv2i32_shift
  URSRAv4i16_shift
  URSRAv8i8_shift
  USDOTlanev8i8
  USDOTv8i8
  USHLv1i64
  USHLv2i32
  USHLv4i16
  USHLv8i8
  USHRd
  USHRv2i32_shift
  USHRv4i16_shift
  USHRv8i8_shift
  USQADDv1i64
  USQADDv2i32
  USQADDv4i16
  USQADDv8i8
  USRAd
  USRAv2i32_shift
  USRAv4i16_shift
  USRAv8i8_shift
  UZP1v2i32
  UZP1v4i16
  UZP1v8i8
  UZP2v2i32
  UZP2v4i16
  UZP2v8i8
  XTNv2i32
  XTNv4i16
  XTNv8i8
  ZIP1v2i32
  ZIP1v4i16
  ZIP1v8i8
  ZIP2v2i32
  ZIP2v4i16
  ZIP2v8i8
2023-05-05 17:26:53 +01:00
Michael Maitland
6e7ca6839d Revert "[RISCV] Add sifive-x280 processor with all of its extensions"
Test still not working...

This reverts commit a11dfd0fe6b1c38495f7de9858a2d1839d2902b9.
2023-05-05 09:03:06 -07:00
Michael Maitland
a11dfd0fe6 [RISCV] Add sifive-x280 processor with all of its extensions
Add sifive-x280 processor that uses the SiFive7 scheduler model.

Differential Revision: https://reviews.llvm.org/D149710
2023-05-05 08:47:57 -07:00
Ronak Chauhan
5f0b92e580 [AMDGPU] Also consider global and scratch instructions when flushing vmcnt counter in loop preheader
Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D149332
2023-05-05 21:12:10 +05:30
Michael Maitland
d6bd4ea354 Revert "[RISCV] Add sifive-x280 processor with all of its extensions"
This commit causes tests to fail.

This reverts commit 55e196e7718c543b4492f2949c13de003a4ba443.
2023-05-05 08:20:18 -07:00
Thomas Lively
72a72315b0 [WebAssembly] Mark @llvm.wasm.shuffle lane indices as immediates
This intrinsic is meant to lower directly to the i8x16.shuffle instruction,
which takes its lane index arguments as immmediates. The ISel for the intrinsic
assumed that the lane index arguments were constants, so bitcode that
"incorrectly" used this intrinsic with non-immediate arguments caused an
assertion failure in the backend.

Avoid the crash by defining the lane index arguments to be immediates, matching
the underlying instruction. Update ISel accordingly. This change means that the
bitcode that previously caused a crash will now fail to validate.

Fixes #55559.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D149898
2023-05-05 08:12:41 -07:00
Michael Maitland
139ece35d8 Revert "[RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td"
This commit was merged incorrectly.

This reverts commit cd02b69e75dd677acdc6c77e6b7bb8d02099b7c0.
2023-05-05 08:02:13 -07:00
Michael Maitland
b77d6f51ba [RISCV] Add Scheduling information for Zfh to SiFive7 model
Everything is the same as F extension, except sqrt and div are 13
cycles faster.

Differential Revision: https://reviews.llvm.org/D149498
2023-05-05 07:55:07 -07:00
Michael Maitland
cd02b69e75 [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td
Based on the following description from Andrew W.

- Instructions not mentioned here behave the same as integer ALU ops
- rev8 only executes in the late-A and late-B ALUs
- shNadd[.uw] only execute on the early-B and late-B ALUs
- clz[w], ctz[w], and orc.b and all rotates only execute in the late-B ALU
- pcnt[w] looks exactly like integer multiply

This patch does not account for early/late ALU in the model. It is coded based
on the pipes only.

Differential Revision: https://reviews.llvm.org/D149497

Co-Authored-By: topperc <craig.topper@sifive.com>
2023-05-05 07:55:07 -07:00
Michael Maitland
55e196e771 [RISCV] Add sifive-x280 processor with all of its extensions
Add sifive-x280 processor that uses the SiFive7 scheduler model.

Differential Revision: https://reviews.llvm.org/D149710
2023-05-05 07:55:07 -07:00
Simon Pilgrim
04e809ab90 [DAG] Add TargetLowering::expandABD and convert X86 lowering to use it
Scalar widening cases are still custom lowered in the X86 backend - we still need to add promotion/legalization support to handle these
2023-05-05 15:13:23 +01:00
Jingu Kang
b18161d785 [AArch64] Handle vector with two different values
If vector has two different values and it can be splitted into two sub
vectors with same length, generate two DUP and CONCAT_VECTORS/VECTOR_SHUFFLE.
For example,

 t22: v16i8 = BUILD_VECTOR t23, t23, t23, t23, t23, t23, t23, t23,
                           t24, t24, t24, t24, t24, t24, t24, t24
==>
   t26: v8i8 = AArch64ISD::DUP t23
   t28: v8i8 = AArch64ISD::DUP t24
 t29: v16i8 = concat_vectors t26, t28

Differential Revision: https://reviews.llvm.org/D148347
2023-05-05 14:42:59 +01:00
Matt Devereau
ea228bd0bd [AArch64] Emit FNMADD instead of FNEG(FMADD)
Emit FNMADD instead of FNEG(FMADD) for optimization levels
above Oz when fast-math flags (nsz+contract) permit it.

Differential Revision: https://reviews.llvm.org/D149260
2023-05-05 13:35:51 +00:00
Matt Devereau
f9ff2468af Revert "[AArch64] Emit FNMADD instead of FNEG(FMADD)"
This reverts commit caa95c2408677d7af8c7be4da203ea9271854f46.
2023-05-05 10:50:23 +00:00
Simon Pilgrim
9a1cb8a856 [X86] Add abds/abdu lowering for scalar i8/i16/i32/i64 types
The next step will be to begin adding generic legalization/lowering support
2023-05-05 11:49:33 +01:00
Serguei Katkov
50cd2ff7bc [X86] Avoid usage constant -1 for fminimum/fmaximum lowering
Instead of equality comparison of value to preferred zero we can check just
the sign of value and if sign is set we should put this value as second operand for minimum
and first operand for maximum.
In this case FMIN/FMAX will choose the right result for 0.f and -0.f comparison.

This allows us:
1. avoid loading of big 64-bit constant for fminimum.
2. for double on non-64-nib platform we need to check only high part of value.
3. test against zero to check sign takes less size of instruction

Additionally, if we know that any of value is guaranteed to be non-zero
we should not care about 0.f and -0.f comparison.

Reviewed By: e-kud
Differential Revision: https://reviews.llvm.org/D149812
2023-05-05 16:24:33 +07:00
Nicolai Hähnle
ef13308b26 AMDGPU/SDAG: Improve {extract,insert}_subvector lowering for 16-bit vectors
v2:
- simplify the escape to TableGen patterns

Differential Revision: https://reviews.llvm.org/D149841
2023-05-05 10:55:18 +02:00
Serguei Katkov
96e09fef3c [X86] Avoid usage constant NaN for fminimum/fmaximum lowering
After applying FMIN/FMAX, if any of operands is NaN, the second operand will be the result.
So all we need is to check whether first operand is NaN and return it or result of FMIN/FMAX.

So we avoid usage of constant NaN in the lowering.

Additionally we can avoid handling NaN after FMIN/FMAX if we are sure that first operand is not NaN.

Reviewed By: e-kud
Differential Revision: https://reviews.llvm.org/D149729
2023-05-05 15:42:54 +07:00
Matt Devereau
caa95c2408 [AArch64] Emit FNMADD instead of FNEG(FMADD)
Emit FNMADD instead of FNEG(FMADD) for optimization levels
above Oz when fast-math flags (nsz+contract) permit it.

Differential Revision: https://reviews.llvm.org/D149260
2023-05-05 08:14:17 +00:00
Jie Fu
814e8d7c5f [RISCV] Omit the template parameters in getSerializableMachineMemOperandTargetFlags()
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D149927
2023-05-05 14:12:16 +08:00
Craig Topper
d421c5f81a [RISCV] Directly create MCOperands from addImplySP in Disassembler. NFC
Instead of passing a constant to DecodeGPRRegisterClass, just create
the X2 register directly.
2023-05-04 22:18:33 -07:00
LiaoChunyu
8cf768839a [RISCV] Remove unused def simm12_plus1 from RISCVInstrInfo.td. NFC
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D149925
2023-05-05 12:53:58 +08:00
Fangrui Song
8e6b3cc4ae [SPIRV] Adapt itaniumDemangle change after itaniumDemangle 2023-05-04 20:47:34 -07:00
Brad Smith
776d50d371 [SPARC][MC] Fix encoding of backwards BPr branches
Make sure that the upper bits of the offset is placed in bits 20-21 of the
instruction word.

This fixes the encoding of backwards (negative offset) BPr branches.

(Previously, the upper two bits of the offset would overwrite parts of the rs1
field, causing it to branch on the wrong register, with the wrong offset)

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D144012
2023-05-04 23:13:08 -04:00
Craig Topper
38007dd394 [RISCV] Promote i1 shuffles to i8 shuffles.
Otherwise I think we extract and use a build_vector. There may be
some more improvements that can be made and there might be some
cases that we should do something different for, but this seemed like a
decent starting point.

Reviewed By: luke

Differential Revision: https://reviews.llvm.org/D149724
2023-05-04 19:44:43 -07:00
Craig Topper
b2420c67e4 [RISCV] Restrict valid indices for cm.jalt to be in [32,255].
Reviewed By: jrtc27

Differential Revision: https://reviews.llvm.org/D149901
2023-05-04 18:02:06 -07:00
Craig Topper
f10bcf6f9d [RISCV] Add vp.icmp/fcmp to RISCVTargetLowering::canSplatOperand. 2023-05-04 16:56:14 -07:00
Ilya Kuklin
c395a84600 [MSP430] Get the DWARF pointer size from MCAsmInfo instead of DataLayout.
This change will allow to put code pointers in DWARF info fields that are larger than actual pointer size, e.g. 16-bit pointers into 32-bit fields.

The need for this came up while creating support for MSP430 in LLDB. MSP430-GCC already generates DWARF info with 32-bit fields, so this change is necessary for LLDB to maintain compatibility with both GCC and LLVM binaries. Moreover, right now in LLDB there is no support for having DWARF pointer size different from ELF header type, e.g. 16-bit DWARF info within ELF32, and it seems there is no such thing as ELF16.

Since other mainline targets are made to have the same pointer size in both MCAsmInfo and DataLayout, there is no need to change anything there.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D148042
2023-05-04 12:37:30 -07:00
Fangrui Song
053bf8640a MS inline asm: remove obsolete code adding AOK_SizeDirective (e.g. dword ptr)
The AOK_SizeDirective part from 5b37c181291210bedfbb7a6af5d51229f3652ef0
(2014-08) seems unneeded nowadays (the root cause has likely been fixed
elsewhere). The part abuses that `call dword ptr foo` assembles the same way as `call
foo` in Intel syntax, which is going to be fixed (changed) by D149579.

The generated object files for
CodeGen/ms-inline-asm{,-functions,-variables,-static-variable}.c and
CodeGenCXX/ms-inline-asm-fields.cpp are unchanged
(-mno-incremental-linker-compatible) with just this patch. When D149579 is
subsequently applied, the FIXME part of `kptr` in
CodeGen/ms-inline-asm-functions.c will be fixed.

Differential Revision: https://reviews.llvm.org/D149695
2023-05-04 09:42:25 -07:00
Evgenii Kudriashov
a82d27a9a6 [X86] Support llvm.{min,max}imum.f{16,32,64}
Addresses https://github.com/llvm/llvm-project/issues/53353

Reviewed By: RKSimon, pengfei

Differential Revision: https://reviews.llvm.org/D145634
2023-05-04 21:04:48 +08:00
Joseph Huber
f05ce9045a [NVPTX] Add NVPTXCtorDtorLoweringPass to handle global ctors / dtors
This patch mostly adapts the existing AMDGPUCtorDtorLoweringPass for use
by the Nvidia backend. This pass transforms the ctor / dtor list into a
kernel call that can be used to invoke those functinos. Furthermore, we
emit globals such that the names and addresses of these constructor
functions can be found by the driver. Unfortunately, since NVPTX has no
way to emit variables at a named section, nor a functioning linker to
provide the begin / end symbols, we need to mangle these names and have
an external application find them.

This work is related to the work in D149398 and D149340.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D149451
2023-05-04 07:13:00 -05:00
Luke Lau
d9683a70fe [RISCV] Fix extract_vector_elt on i1 at idx 0 being inverted
It looks like the intention here is to truncate a XLenVT -> i1, in
which case we should be emitting snez instead of sneq if I'm understanding
correctly.

Reviewed By: jacquesguan, frasercrmck

Differential Revision: https://reviews.llvm.org/D149732
2023-05-04 11:45:35 +01:00
Luke Lau
9e9bf1e3ed [RISCV] Use setcc to truncate results in widenVectorOpsToi8
To avoid an unnecessary vand.vi

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D149771
2023-05-04 10:49:27 +01:00
NAKAMURA Takumi
00f8bbf07d Fix a warning in D149762 [-Wunused-variable] 2023-05-04 12:11:05 +09:00
Fangrui Song
b05cd680ea MCInstrAnalysis: make GotPltSectionVA x86-32 specific
GotPltSectionVA is specific to x86-32 PIC PLT entries.
Let's remove the argument from the generic interface.

As a side effect of not requiring .got.plt, this simplification
addresses a subset of https://github.com/llvm/llvm-project/issues/62537
by enabling .plt dumping for some ld.bfd -z now linked x86-32/x86-64 images
without .got.plt
2023-05-03 19:21:01 -07:00
Shao-Ce SUN
2dc0fa050e [RISCV][CodeGen] Support Zdinx on RV64 codegen
This patch was split from D122918 . Co-Author: @liaolucy @realqhc

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D149665
2023-05-04 09:00:40 +08:00
Thomas Lively
abdb5e041c [WebAssembly] Remove incorrect result from wasm64 store_lane instructions
The wasm64 versions of the v128.storeX_lane instructions was incorrectly defined
as returning a v128 value, which resulted in spurious drop instructions being
emitted and causing validation to fail. This was not caught earlier because
wasm64 has been experimental and not well tested. Update the relevant test file
to test both wasm32 and wasm64.

Fixes #62443.

Differential Revision: https://reviews.llvm.org/D149780
2023-05-03 16:00:20 -07:00
Shubham Sandeep Rastogi
ee58f49a78 Change if() continue; to an assert if a DBG_VALUE or DBG_VALUE_LIST returns a null DILocalVariable
A  DBG_VALUE or DBG_VALUE_LIST must always return a non-null
DILocalVariable, the ARMLoadStoreOptimizer code that move’s DBG_VALUE
and DBG_VALUE_LIST instructions if their corresponding loads have been
moved, currently just continues if it finds a DBG_VALUE or
DBG_VALUE_LIST with a null DILocalVariable, change that to an assert.

Differential revision: https://reviews.llvm.org/D149762
2023-05-03 14:19:20 -07:00
Krzysztof Drewniak
f0415f2a45 Re-land "[AMDGPU] Define data layout entries for buffers""
Re-land D145441 with data layout upgrade code fixed to not break OpenMP.

This reverts commit 3f2fbe92d0f40bcb46db7636db9ec3f7e7899b27.

Differential Revision: https://reviews.llvm.org/D149776
2023-05-03 19:43:56 +00:00
Philip Reames
0d19739768 [RISCV] Don't overcount FP constants in lowerBUILD_VECTOR
If the value count is > 1, we use a splat and thus only materialize the constant once, not once per element.
2023-05-03 12:21:18 -07:00
Craig Topper
5c34cdaad7 [RISCV] Pass FeatureBitset to computeTargetABI by const reference. NFC 2023-05-03 10:18:33 -07:00
Craig Topper
1cef77de12 [RISCV] Fix intrinsic name in comment for lowerInterleavedLoad/lowerInterleavedStore. NFC
Differential Revision: https://reviews.llvm.org/D149714
2023-05-03 09:47:53 -07:00
Krzysztof Drewniak
3f2fbe92d0 Revert "[AMDGPU] Define data layout entries for buffers"
This reverts commit f9c1ede2543b37fabe9f2d8f8fed5073c475d850.

Differential Revision: https://reviews.llvm.org/D149758
2023-05-03 16:11:00 +00:00