181ad6265SDimitry Andric//===-- RISCVInstrInfoZicbo.td - RISC-V CMO instructions ---*- tablegen -*-===// 281ad6265SDimitry Andric// 381ad6265SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 481ad6265SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 581ad6265SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 681ad6265SDimitry Andric// 781ad6265SDimitry Andric//===----------------------------------------------------------------------===// 881ad6265SDimitry Andric// 981ad6265SDimitry Andric// This file describes the RISC-V instructions from the standard Base Cache 10bdd1243dSDimitry Andric// Management Operation ISA Extensions document (Zicbom, Zicboz, and Zicbop). 1181ad6265SDimitry Andric// 1281ad6265SDimitry Andric//===----------------------------------------------------------------------===// 1381ad6265SDimitry Andric 1481ad6265SDimitry Andric//===----------------------------------------------------------------------===// 1581ad6265SDimitry Andric// Operand definitions. 1681ad6265SDimitry Andric//===----------------------------------------------------------------------===// 1781ad6265SDimitry Andric 1881ad6265SDimitry Andric// A 12-bit signed immediate where the least significant five bits are zero. 19*5f757f3fSDimitry Andricdef simm12_lsb00000 : RISCVOp, 2081ad6265SDimitry Andric ImmLeaf<XLenVT, [{return isShiftedInt<7, 5>(Imm);}]> { 2181ad6265SDimitry Andric let ParserMatchClass = SImmAsmOperand<12, "Lsb00000">; 2281ad6265SDimitry Andric let EncoderMethod = "getImmOpValue"; 2381ad6265SDimitry Andric let DecoderMethod = "decodeSImmOperand<12>"; 2481ad6265SDimitry Andric let MCOperandPredicate = [{ 2581ad6265SDimitry Andric int64_t Imm; 2681ad6265SDimitry Andric if (MCOp.evaluateAsConstantImm(Imm)) 2781ad6265SDimitry Andric return isShiftedInt<7, 5>(Imm); 2881ad6265SDimitry Andric return MCOp.isBareSymbolRef(); 2981ad6265SDimitry Andric }]; 3081ad6265SDimitry Andric let OperandType = "OPERAND_SIMM12_LSB00000"; 3181ad6265SDimitry Andric} 3281ad6265SDimitry Andric 3381ad6265SDimitry Andric//===----------------------------------------------------------------------===// 3481ad6265SDimitry Andric// Instruction Class Templates 3581ad6265SDimitry Andric//===----------------------------------------------------------------------===// 3681ad6265SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 1 in 3781ad6265SDimitry Andricclass CBO_r<bits<12> optype, string opcodestr> 3881ad6265SDimitry Andric : RVInstI<0b010, OPC_MISC_MEM, (outs), (ins GPRMemZeroOffset:$rs1), 3981ad6265SDimitry Andric opcodestr, "$rs1"> { 4081ad6265SDimitry Andric let imm12 = optype; 4181ad6265SDimitry Andric let rd = 0b00000; 4281ad6265SDimitry Andric} 4381ad6265SDimitry Andric 4406c3fb27SDimitry Andriclet hasSideEffects = 0, mayLoad = 1, mayStore = 1 in 4581ad6265SDimitry Andricclass Prefetch_ri<bits<5> optype, string opcodestr> 4681ad6265SDimitry Andric : RVInstS<0b110, OPC_OP_IMM, (outs), (ins GPR:$rs1, simm12_lsb00000:$imm12), 4781ad6265SDimitry Andric opcodestr, "${imm12}(${rs1})"> { 4881ad6265SDimitry Andric let Inst{11-7} = 0b00000; 4981ad6265SDimitry Andric let rs2 = optype; 5081ad6265SDimitry Andric} 5181ad6265SDimitry Andric 5281ad6265SDimitry Andric//===----------------------------------------------------------------------===// 5381ad6265SDimitry Andric// Instructions 5481ad6265SDimitry Andric//===----------------------------------------------------------------------===// 5581ad6265SDimitry Andric 5681ad6265SDimitry Andriclet Predicates = [HasStdExtZicbom] in { 5781ad6265SDimitry Andricdef CBO_CLEAN : CBO_r<0b000000000001, "cbo.clean">, Sched<[]>; 5881ad6265SDimitry Andricdef CBO_FLUSH : CBO_r<0b000000000010, "cbo.flush">, Sched<[]>; 5981ad6265SDimitry Andricdef CBO_INVAL : CBO_r<0b000000000000, "cbo.inval">, Sched<[]>; 6081ad6265SDimitry Andric} // Predicates = [HasStdExtZicbom] 6181ad6265SDimitry Andric 6281ad6265SDimitry Andriclet Predicates = [HasStdExtZicboz] in { 6381ad6265SDimitry Andricdef CBO_ZERO : CBO_r<0b000000000100, "cbo.zero">, Sched<[]>; 6481ad6265SDimitry Andric} // Predicates = [HasStdExtZicboz] 6581ad6265SDimitry Andric 6681ad6265SDimitry Andriclet Predicates = [HasStdExtZicbop] in { 6781ad6265SDimitry Andricdef PREFETCH_I : Prefetch_ri<0b00000, "prefetch.i">, Sched<[]>; 6881ad6265SDimitry Andricdef PREFETCH_R : Prefetch_ri<0b00001, "prefetch.r">, Sched<[]>; 6981ad6265SDimitry Andricdef PREFETCH_W : Prefetch_ri<0b00011, "prefetch.w">, Sched<[]>; 7081ad6265SDimitry Andric} // Predicates = [HasStdExtZicbop] 7106c3fb27SDimitry Andric 7206c3fb27SDimitry Andric//===----------------------------------------------------------------------===// 7306c3fb27SDimitry Andric// Patterns 7406c3fb27SDimitry Andric//===----------------------------------------------------------------------===// 7506c3fb27SDimitry Andric 76*5f757f3fSDimitry Andricdef AddrRegImmLsb00000 : ComplexPattern<iPTR, 2, "SelectAddrRegImmLsb00000">; 77*5f757f3fSDimitry Andric 7806c3fb27SDimitry Andriclet Predicates = [HasStdExtZicbop] in { 79*5f757f3fSDimitry Andric def : Pat<(prefetch (AddrRegImmLsb00000 (XLenVT GPR:$rs1), simm12_lsb00000:$imm12), 80*5f757f3fSDimitry Andric timm, timm, (i32 0)), 81*5f757f3fSDimitry Andric (PREFETCH_I GPR:$rs1, simm12_lsb00000:$imm12)>; 82*5f757f3fSDimitry Andric def : Pat<(prefetch (AddrRegImmLsb00000 (XLenVT GPR:$rs1), simm12_lsb00000:$imm12), 83*5f757f3fSDimitry Andric (i32 0), timm, (i32 1)), 84*5f757f3fSDimitry Andric (PREFETCH_R GPR:$rs1, simm12_lsb00000:$imm12)>; 85*5f757f3fSDimitry Andric def : Pat<(prefetch (AddrRegImmLsb00000 (XLenVT GPR:$rs1), simm12_lsb00000:$imm12), 86*5f757f3fSDimitry Andric (i32 1), timm, (i32 1)), 87*5f757f3fSDimitry Andric (PREFETCH_W GPR:$rs1, simm12_lsb00000:$imm12)>; 8806c3fb27SDimitry Andric} 89