1*b3edf446SDimitry Andric//==----- RISCVMacroFusion.td - Macro Fusion Definitions -----*- tablegen -*-=// 2*b3edf446SDimitry Andric// 3*b3edf446SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*b3edf446SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5*b3edf446SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*b3edf446SDimitry Andric// 7*b3edf446SDimitry Andric//===----------------------------------------------------------------------===// 8*b3edf446SDimitry Andric 9*b3edf446SDimitry Andric// ===---------------------------------------------------------------------===// 10*b3edf446SDimitry Andric// The following definitions describe the macro fusion predicators. 11*b3edf446SDimitry Andric 12*b3edf446SDimitry Andric// Fuse LUI followed by ADDI or ADDIW: 13*b3edf446SDimitry Andric// rd = imm[31:0] which decomposes to 14*b3edf446SDimitry Andric// lui rd, imm[31:12] 15*b3edf446SDimitry Andric// addi(w) rd, rd, imm[11:0] 16*b3edf446SDimitry Andricdef TuneLUIADDIFusion 17*b3edf446SDimitry Andric : SimpleFusion<"lui-addi-fusion", "HasLUIADDIFusion", 18*b3edf446SDimitry Andric "Enable LUI+ADDI macro fusion", 19*b3edf446SDimitry Andric CheckOpcode<[LUI]>, 20*b3edf446SDimitry Andric CheckOpcode<[ADDI, ADDIW]>>; 21*b3edf446SDimitry Andric 22*b3edf446SDimitry Andric// Fuse AUIPC followed by ADDI: 23*b3edf446SDimitry Andric// auipc rd, imm20 24*b3edf446SDimitry Andric// addi rd, rd, imm12 25*b3edf446SDimitry Andricdef TuneAUIPCADDIFusion 26*b3edf446SDimitry Andric : SimpleFusion<"auipc-addi-fusion", "HasAUIPCADDIFusion", 27*b3edf446SDimitry Andric "Enable AUIPC+ADDI macrofusion", 28*b3edf446SDimitry Andric CheckOpcode<[AUIPC]>, 29*b3edf446SDimitry Andric CheckOpcode<[ADDI]>>; 30*b3edf446SDimitry Andric 31*b3edf446SDimitry Andric// Fuse zero extension of halfword: 32*b3edf446SDimitry Andric// slli rd, rs1, 48 33*b3edf446SDimitry Andric// srli rd, rd, 48 34*b3edf446SDimitry Andricdef TuneZExtHFusion 35*b3edf446SDimitry Andric : SimpleFusion<"zexth-fusion", "HasZExtHFusion", 36*b3edf446SDimitry Andric "Enable SLLI+SRLI to be fused to zero extension of halfword", 37*b3edf446SDimitry Andric CheckAll<[ 38*b3edf446SDimitry Andric CheckOpcode<[SLLI]>, 39*b3edf446SDimitry Andric CheckIsImmOperand<2>, 40*b3edf446SDimitry Andric CheckImmOperand<2, 48> 41*b3edf446SDimitry Andric ]>, 42*b3edf446SDimitry Andric CheckAll<[ 43*b3edf446SDimitry Andric CheckOpcode<[SRLI]>, 44*b3edf446SDimitry Andric CheckIsImmOperand<2>, 45*b3edf446SDimitry Andric CheckImmOperand<2, 48> 46*b3edf446SDimitry Andric ]>>; 47*b3edf446SDimitry Andric 48*b3edf446SDimitry Andric// Fuse zero extension of word: 49*b3edf446SDimitry Andric// slli rd, rs1, 32 50*b3edf446SDimitry Andric// srli rd, rd, 32 51*b3edf446SDimitry Andricdef TuneZExtWFusion 52*b3edf446SDimitry Andric : SimpleFusion<"zextw-fusion", "HasZExtWFusion", 53*b3edf446SDimitry Andric "Enable SLLI+SRLI to be fused to zero extension of word", 54*b3edf446SDimitry Andric CheckAll<[ 55*b3edf446SDimitry Andric CheckOpcode<[SLLI]>, 56*b3edf446SDimitry Andric CheckIsImmOperand<2>, 57*b3edf446SDimitry Andric CheckImmOperand<2, 32> 58*b3edf446SDimitry Andric ]>, 59*b3edf446SDimitry Andric CheckAll<[ 60*b3edf446SDimitry Andric CheckOpcode<[SRLI]>, 61*b3edf446SDimitry Andric CheckIsImmOperand<2>, 62*b3edf446SDimitry Andric CheckImmOperand<2, 32> 63*b3edf446SDimitry Andric ]>>; 64*b3edf446SDimitry Andric 65*b3edf446SDimitry Andric// Fuse shifted zero extension of word: 66*b3edf446SDimitry Andric// slli rd, rs1, 32 67*b3edf446SDimitry Andric// srli rd, rd, x 68*b3edf446SDimitry Andric// where 0 <= x < 32 69*b3edf446SDimitry Andricdef TuneShiftedZExtWFusion 70*b3edf446SDimitry Andric : SimpleFusion<"shifted-zextw-fusion", "HasShiftedZExtWFusion", 71*b3edf446SDimitry Andric "Enable SLLI+SRLI to be fused when computing (shifted) word zero extension", 72*b3edf446SDimitry Andric CheckAll<[ 73*b3edf446SDimitry Andric CheckOpcode<[SLLI]>, 74*b3edf446SDimitry Andric CheckIsImmOperand<2>, 75*b3edf446SDimitry Andric CheckImmOperand<2, 32> 76*b3edf446SDimitry Andric ]>, 77*b3edf446SDimitry Andric CheckAll<[ 78*b3edf446SDimitry Andric CheckOpcode<[SRLI]>, 79*b3edf446SDimitry Andric CheckIsImmOperand<2>, 80*b3edf446SDimitry Andric CheckImmOperandRange<2, 0, 31> 81*b3edf446SDimitry Andric ]>>; 82*b3edf446SDimitry Andric 83*b3edf446SDimitry Andric// Fuse load with add: 84*b3edf446SDimitry Andric// add rd, rs1, rs2 85*b3edf446SDimitry Andric// ld rd, 0(rd) 86*b3edf446SDimitry Andricdef TuneLDADDFusion 87*b3edf446SDimitry Andric : SimpleFusion<"ld-add-fusion", "HasLDADDFusion", "Enable LD+ADD macrofusion", 88*b3edf446SDimitry Andric CheckOpcode<[ADD]>, 89*b3edf446SDimitry Andric CheckAll<[ 90*b3edf446SDimitry Andric CheckOpcode<[LD]>, 91*b3edf446SDimitry Andric CheckIsImmOperand<2>, 92*b3edf446SDimitry Andric CheckImmOperand<2, 0> 93*b3edf446SDimitry Andric ]>>; 94