In particular, precompiled headers ideally won't depend on any.
$(2)_deps := $$(patsubst %.o, %.d, $$($(2)_objs))
$(2)_c_deps := $$(patsubst %.o, %.d, $$($(2)_c_objs))
$(2)_pch_deps := $$(patsubst %.h, %.d, $$($(2)_precompiled_hdrs))
-$$($(2)_pch) : %.h.gch : %.h $$($(2)_gen_hdrs)
+$$($(2)_pch) : %.h.gch : %.h
$(COMPILE) $$<
# If using clang, don't depend (and thus don't build) precompiled headers
$$($(2)_objs) : %.o : %.cc $$($(2)_gen_hdrs) $(if $(filter-out clang,$(CC)),$$($(2)_pch))
#!/bin/sh
-echo \#define ICACHE_SIZE $1
n=$(($1-1))
-echo \#define ICACHE_SWITCH \\
for i in `seq 0 $n`
do
- echo case $i: ICACHE_ACCESS\($i\)\; \\
+ echo case $i: ICACHE_ACCESS\($i\)\;
done
echo
void mmu_t::flush_icache()
{
- for (size_t i = 0; i < ICACHE_SIZE; i++)
+ for (size_t i = 0; i < ICACHE_ENTRIES; i++)
icache[i].tag = -1;
}
#define _RISCV_MMU_H
#include "decode.h"
-#include "icache.h"
#include "trap.h"
#include "common.h"
#include "config.h"
store_func(uint32)
store_func(uint64)
+ static const reg_t ICACHE_ENTRIES = 1024;
+
inline size_t icache_index(reg_t addr)
{
// for instruction sizes != 4, this hash still works but is suboptimal
- return (addr / 4) % ICACHE_SIZE;
+ return (addr / 4) % ICACHE_ENTRIES;
}
// load instruction from memory at aligned address.
memtracer_list_t tracer;
// implement an instruction cache for simulator performance
- icache_entry_t icache[ICACHE_SIZE];
+ icache_entry_t icache[ICACHE_ENTRIES];
// implement a TLB for simulator performance
static const reg_t TLB_ENTRIES = 256;
#include "sim.h"
#include "htif.h"
#include "disasm.h"
-#include "icache.h"
#include <cinttypes>
#include <cmath>
#include <cstdlib>
ic_entry++; \
pc = execute_insn(this, pc, fetch); \
instret++; \
- if (idx < ICACHE_SIZE-1 && unlikely(ic_entry->tag != pc)) break; \
+ if (idx == mmu_t::ICACHE_ENTRIES-1) break; \
+ if (unlikely(ic_entry->tag != pc)) break; \
}
- switch (idx)
- {
- ICACHE_SWITCH; // auto-generated into icache.h
+ switch (idx) {
+ #include "icache.h"
}
}
}
riscv_gen_srcs = \
$(addsuffix .cc, $(call get_insn_list,$(src_dir)/riscv/encoding.h))
-icache.h:
- $(src_dir)/riscv/gen_icache 1024 > $@.tmp
+icache_entries := `grep "ICACHE_ENTRIES =" $(src_dir)/riscv/mmu.h | sed 's/.* = \(.*\);/\1/'`
+
+icache.h: mmu.h
+ $(src_dir)/riscv/gen_icache $(icache_entries) > $@.tmp
mv $@.tmp $@
$(riscv_gen_srcs): %.cc: insns/%.h insn_template.cc