No public description PiperOrigin-RevId: 950393090 Change-Id: I299f40edb2e7ba2fa7bd965ac1390225fa2f87eb
diff --git a/riscv/BUILD b/riscv/BUILD index b0a7f83..7ddc997 100644 --- a/riscv/BUILD +++ b/riscv/BUILD
@@ -28,6 +28,8 @@ exports_files([ "riscv_zvt.isa", "riscv_zvt.bin_fmt", + "riscv_zicbom.isa", + "riscv_zicbom.bin_fmt", "LICENSE", "riscv32g.bin_fmt", "riscv32g.isa", @@ -287,16 +289,16 @@ srcs = [ "riscv_zc_instructions.cc", "riscv_zhintpause_instructions.cc", + "riscv_zicbom_instructions.cc", "riscv_zicbop_instructions.cc", - "riscv_zicond_instructions.cc", "riscv_zihintntl_instructions.cc", "riscv_zimop_instructions.cc", ], hdrs = [ "riscv_zc_instructions.h", "riscv_zhintpause_instructions.h", + "riscv_zicbom_instructions.h", "riscv_zicbop_instructions.h", - "riscv_zicond_instructions.h", "riscv_zihintntl_instructions.h", "riscv_zimop_instructions.h", ], @@ -502,6 +504,7 @@ "riscv_vector.isa", "riscv_zc.isa", "riscv_zhintpause.isa", + "riscv_zicbom.isa", "riscv_zicbop.isa", "riscv_zicond.isa", "riscv_zihintntl.isa", @@ -530,6 +533,7 @@ "riscv_format32.bin_fmt", "riscv_zc.bin_fmt", "riscv_zhintpause.bin_fmt", + "riscv_zicbom.bin_fmt", "riscv_zicbop.bin_fmt", "riscv_zicond.bin_fmt", "riscv_zihintntl.bin_fmt",
diff --git a/riscv/riscv_zicbom.bin_fmt b/riscv/riscv_zicbom.bin_fmt new file mode 100644 index 0000000..d05c245 --- /dev/null +++ b/riscv/riscv_zicbom.bin_fmt
@@ -0,0 +1,24 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file defines the encoding for the cache block management instructions in the +// Zicbom extension. + +#include "riscv_format32.bin_fmt" + +instruction group RiscVZicbom[32] : Inst32Format { + cbo_clean : IType : u_imm12 == 0b0000'0000'0001, rd == 0b00000, func3 == 0b010, opcode == 0b000'1111; + cbo_flush : IType : u_imm12 == 0b0000'0000'0010, rd == 0b00000, func3 == 0b010, opcode == 0b000'1111; + cbo_inval : IType : u_imm12 == 0b0000'0000'0000, rd == 0b00000, func3 == 0b010, opcode == 0b000'1111; +}
diff --git a/riscv/riscv_zicbom.isa b/riscv/riscv_zicbom.isa new file mode 100644 index 0000000..18de764 --- /dev/null +++ b/riscv/riscv_zicbom.isa
@@ -0,0 +1,48 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file defines the cache block management instructions in the Zicbom extension. + +slot riscv_zicbom32 { + includes { + #include "riscv/riscv_zicbom_instructions.h" + } + default size = 4; + opcodes { + cbo_clean{: rs1 :}, + resources: { rs1 :}, + disasm: "cbo.clean", "0(%rs1)", + semfunc: "&RV32::RiscVCboClean"; + cbo_flush{: rs1 :}, + resources: { rs1 :}, + disasm: "cbo.flush", "0(%rs1)", + semfunc: "&RV32::RiscVCboFlush"; + cbo_inval{: rs1 :}, + resources: { rs1 :}, + disasm: "cbo.inval", "0(%rs1)", + semfunc: "&RV32::RiscVCboInval"; + } +} + +slot riscv_zicbom64 : riscv_zicbom32 { + includes { + #include "riscv/riscv_zicbom_instructions.h" + } + default size = 4; + opcodes { + cbo_clean = override, semfunc: "&RV64::RiscVCboClean"; + cbo_flush = override, semfunc: "&RV64::RiscVCboFlush"; + cbo_inval = override, semfunc: "&RV64::RiscVCboInval"; + } +}
diff --git a/riscv/riscv_zicbom_instructions.cc b/riscv/riscv_zicbom_instructions.cc new file mode 100644 index 0000000..0232463 --- /dev/null +++ b/riscv/riscv_zicbom_instructions.cc
@@ -0,0 +1,43 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "riscv/riscv_zicbom_instructions.h" + +#include "mpact/sim/generic/instruction.h" + +// This file contains the definitions of the instruction semantic functions +// for the cache block management instructions in the Zicbom extension. +// For now, these instructions are implemented as no-ops. + +namespace mpact::sim::riscv { + +using ::mpact::sim::generic::Instruction; + +namespace RV32 { + +void RiscVCboClean(const Instruction* inst) { /* empty */ } +void RiscVCboFlush(const Instruction* inst) { /* empty */ } +void RiscVCboInval(const Instruction* inst) { /* empty */ } + +} // namespace RV32 + +namespace RV64 { + +void RiscVCboClean(const Instruction* inst) { /* empty */ } +void RiscVCboFlush(const Instruction* inst) { /* empty */ } +void RiscVCboInval(const Instruction* inst) { /* empty */ } + +} // namespace RV64 + +} // namespace mpact::sim::riscv
diff --git a/riscv/riscv_zicbom_instructions.h b/riscv/riscv_zicbom_instructions.h new file mode 100644 index 0000000..51f30d6 --- /dev/null +++ b/riscv/riscv_zicbom_instructions.h
@@ -0,0 +1,49 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_MPACT_RISCV_RISCV_ZICBOM_INSTRUCTIONS_H_ +#define THIRD_PARTY_MPACT_RISCV_RISCV_ZICBOM_INSTRUCTIONS_H_ + +#include "mpact/sim/generic/instruction.h" + +// This file contains the declarations of the instruction semantic functions +// for the cache block management instructions in the Zicbom extension. + +namespace mpact::sim::riscv { + +using ::mpact::sim::generic::Instruction; + +namespace RV32 { + +// Each of these instructions takes one source operand: rs1, which contains the +// base address of the cache block to be cleaned, flushed, or invalidated. +void RiscVCboClean(const Instruction* inst); +void RiscVCboFlush(const Instruction* inst); +void RiscVCboInval(const Instruction* inst); + +} // namespace RV32 + +namespace RV64 { + +// Each of these instructions takes one source operand: rs1, which contains the +// base address of the cache block to be cleaned, flushed, or invalidated. +void RiscVCboClean(const Instruction* inst); +void RiscVCboFlush(const Instruction* inst); +void RiscVCboInval(const Instruction* inst); + +} // namespace RV64 + +} // namespace mpact::sim::riscv + +#endif // THIRD_PARTY_MPACT_RISCV_RISCV_ZICBOM_INSTRUCTIONS_H_
diff --git a/riscv/rvm23.bin_fmt b/riscv/rvm23.bin_fmt index b395e68..f607148 100644 --- a/riscv/rvm23.bin_fmt +++ b/riscv/rvm23.bin_fmt
@@ -34,6 +34,7 @@ RiscVZihintntl, // Cache prefetch instructions. RiscVZicbop, + RiscVZicbom, }; RVM23Inst16 = { RiscVZcmop, @@ -50,6 +51,7 @@ #include "riscv32zb.bin_fmt" #include "riscv_zc.bin_fmt" #include "riscv_zhintpause.bin_fmt" +#include "riscv_zicbom.bin_fmt" #include "riscv_zicbop.bin_fmt" #include "riscv_zicond.bin_fmt" #include "riscv_zihintntl.bin_fmt"
diff --git a/riscv/rvm23.isa b/riscv/rvm23.isa index 3ef7b24..91fa8eb 100644 --- a/riscv/rvm23.isa +++ b/riscv/rvm23.isa
@@ -23,6 +23,7 @@ #include "riscv32zb.isa" #include "riscv_vector.isa" #include "riscv_zc.isa" +#include "riscv_zicbom.isa" #include "riscv_zicbop.isa" #include "riscv_zicond.isa" #include "riscv_zimop.isa" @@ -52,6 +53,7 @@ riscv_zcf32, riscv_zcmp32, riscv_zcmt32, + riscv_zicbom32, riscv_zicbop32 { default opcode = disasm: "Illegal instruction at 0x%(@:08x)",