mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Tighten up internal vs external functions, which lets optimiser do a better job, self.bin about 10% smaller.
This commit is contained in:
parent
07bab3cca6
commit
f917ba38ff
3 changed files with 22 additions and 21 deletions
Binary file not shown.
|
|
@ -182,7 +182,7 @@ bool get_safeptr_null_terminated(uvm32_state_t *vmst, uint32_t addr, uvm32_slice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_safeptr(uvm32_state_t *vmst, uint32_t addr, uint32_t len, uvm32_slice_t *buf) {
|
static bool get_safeptr(uvm32_state_t *vmst, uint32_t addr, uint32_t len, uvm32_slice_t *buf) {
|
||||||
if (MINIRV32_MMIO_RANGE(addr)) {
|
if (MINIRV32_MMIO_RANGE(addr)) {
|
||||||
if (vmst->_extram == NULL) {
|
if (vmst->_extram == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -408,7 +408,7 @@ uvm32_slice_t uvm32_arg_getslice_fixed(uvm32_state_t *vmst, uvm32_evt_t *evt, uv
|
||||||
return scb;
|
return scb;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp) {
|
static uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp) {
|
||||||
uvm32_state_t *vmst = (uvm32_state_t *)userdata;
|
uvm32_state_t *vmst = (uvm32_state_t *)userdata;
|
||||||
addr -= UVM32_EXTRAM_BASE;
|
addr -= UVM32_EXTRAM_BASE;
|
||||||
|
|
||||||
|
|
@ -445,7 +445,7 @@ uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t _uvm32_extramStore(void *userdata, uint32_t addr, uint32_t val, uint32_t accessTyp) {
|
static uint32_t _uvm32_extramStore(void *userdata, uint32_t addr, uint32_t val, uint32_t accessTyp) {
|
||||||
uvm32_state_t *vmst = (uvm32_state_t *)userdata;
|
uvm32_state_t *vmst = (uvm32_state_t *)userdata;
|
||||||
addr -= UVM32_EXTRAM_BASE;
|
addr -= UVM32_EXTRAM_BASE;
|
||||||
if (vmst->_extram != NULL) {
|
if (vmst->_extram != NULL) {
|
||||||
|
|
@ -489,34 +489,34 @@ uint32_t uvm32_getProgramCounter(const uvm32_state_t *vmst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access of memory bus in alignment safe way
|
// Access of memory bus in alignment safe way
|
||||||
void _uvm32_store4(void *p, uint32_t off, uint32_t val) {
|
static void _uvm32_store4(void *p, uint32_t off, uint32_t val) {
|
||||||
UVM32_MEMCPY((uint8_t *)p + off, &val, 4);
|
UVM32_MEMCPY((uint8_t *)p + off, &val, 4);
|
||||||
}
|
}
|
||||||
void _uvm32_store2(void *p, uint32_t off, uint16_t val) {
|
static void _uvm32_store2(void *p, uint32_t off, uint16_t val) {
|
||||||
UVM32_MEMCPY((uint8_t *)p + off, &val, 2);
|
UVM32_MEMCPY((uint8_t *)p + off, &val, 2);
|
||||||
}
|
}
|
||||||
void _uvm32_store1(void *p, uint32_t off, uint8_t val) {
|
static void _uvm32_store1(void *p, uint32_t off, uint8_t val) {
|
||||||
((uint8_t *)p)[off] = val;
|
((uint8_t *)p)[off] = val;
|
||||||
}
|
}
|
||||||
uint32_t _uvm32_load4(void *p, uint32_t off) {
|
static uint32_t _uvm32_load4(void *p, uint32_t off) {
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
UVM32_MEMCPY(&v, (uint8_t *)p + off, 4);
|
UVM32_MEMCPY(&v, (uint8_t *)p + off, 4);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
uint16_t _uvm32_load2(void *p, uint32_t off) {
|
static uint16_t _uvm32_load2(void *p, uint32_t off) {
|
||||||
uint16_t v;
|
uint16_t v;
|
||||||
UVM32_MEMCPY(&v, (uint8_t *)p + off, 2);
|
UVM32_MEMCPY(&v, (uint8_t *)p + off, 2);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
uint8_t _uvm32_load1(void *p, uint32_t off) {
|
static uint8_t _uvm32_load1(void *p, uint32_t off) {
|
||||||
return ((uint8_t *)p)[off];
|
return ((uint8_t *)p)[off];
|
||||||
}
|
}
|
||||||
int16_t _uvm32_load2s(void *p, uint32_t off) {
|
static int16_t _uvm32_load2s(void *p, uint32_t off) {
|
||||||
int16_t v;
|
int16_t v;
|
||||||
UVM32_MEMCPY(&v, (uint8_t *)p + off, 2);
|
UVM32_MEMCPY(&v, (uint8_t *)p + off, 2);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
int8_t _uvm32_load1s(void *p, uint32_t off) {
|
static int8_t _uvm32_load1s(void *p, uint32_t off) {
|
||||||
return ((int8_t *)p)[off];
|
return ((int8_t *)p)[off];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,18 +47,8 @@ SOFTWARE.
|
||||||
#define MINIRV32_NO_BREAKPOINT_NO_INTERRUPTS
|
#define MINIRV32_NO_BREAKPOINT_NO_INTERRUPTS
|
||||||
#define MINI_RV32_RAM_SIZE UVM32_MEMORY_SIZE
|
#define MINI_RV32_RAM_SIZE UVM32_MEMORY_SIZE
|
||||||
#define MINIRV32_POSTEXEC(pc, ir, retval) {if (retval > 0) return retval;}
|
#define MINIRV32_POSTEXEC(pc, ir, retval) {if (retval > 0) return retval;}
|
||||||
uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp);
|
|
||||||
uint32_t _uvm32_extramStore(void *userdata, uint32_t addr, uint32_t val, uint32_t accessTyp);
|
|
||||||
#define MINIRV32_HANDLE_MEM_LOAD_CONTROL( addy, rval ) rval = _uvm32_extramLoad(userdata, addy, ( ir >> 12 ) & 0x7);
|
#define MINIRV32_HANDLE_MEM_LOAD_CONTROL( addy, rval ) rval = _uvm32_extramLoad(userdata, addy, ( ir >> 12 ) & 0x7);
|
||||||
#define MINIRV32_HANDLE_MEM_STORE_CONTROL( addy, val ) if( _uvm32_extramStore(userdata, addy, val, ( ir >> 12 ) & 0x7) ) return val;
|
#define MINIRV32_HANDLE_MEM_STORE_CONTROL( addy, val ) if( _uvm32_extramStore(userdata, addy, val, ( ir >> 12 ) & 0x7) ) return val;
|
||||||
void _uvm32_store4(void *p, uint32_t off, uint32_t val);
|
|
||||||
void _uvm32_store2(void *p, uint32_t off, uint16_t val);
|
|
||||||
void _uvm32_store1(void *p, uint32_t off, uint8_t val);
|
|
||||||
uint32_t _uvm32_load4(void *p, uint32_t off);
|
|
||||||
uint16_t _uvm32_load2(void *p, uint32_t off);
|
|
||||||
uint8_t _uvm32_load1(void *p, uint32_t off);
|
|
||||||
int16_t _uvm32_load2s(void *p, uint32_t off);
|
|
||||||
int8_t _uvm32_load1s(void *p, uint32_t off);
|
|
||||||
#define MINIRV32_CUSTOM_MEMORY_BUS
|
#define MINIRV32_CUSTOM_MEMORY_BUS
|
||||||
#define MINIRV32_STORE4( ofs, val ) _uvm32_store4(image, ofs, val)
|
#define MINIRV32_STORE4( ofs, val ) _uvm32_store4(image, ofs, val)
|
||||||
#define MINIRV32_STORE2( ofs, val ) _uvm32_store2(image, ofs, val)
|
#define MINIRV32_STORE2( ofs, val ) _uvm32_store2(image, ofs, val)
|
||||||
|
|
@ -70,6 +60,17 @@ int8_t _uvm32_load1s(void *p, uint32_t off);
|
||||||
#define MINIRV32_LOAD1_SIGNED( ofs ) _uvm32_load1s(image, ofs)
|
#define MINIRV32_LOAD1_SIGNED( ofs ) _uvm32_load1s(image, ofs)
|
||||||
#ifndef MINIRV32_IMPLEMENTATION
|
#ifndef MINIRV32_IMPLEMENTATION
|
||||||
#define MINIRV32_STEPPROTO
|
#define MINIRV32_STEPPROTO
|
||||||
|
#else
|
||||||
|
static uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp);
|
||||||
|
static uint32_t _uvm32_extramStore(void *userdata, uint32_t addr, uint32_t val, uint32_t accessTyp);
|
||||||
|
static void _uvm32_store4(void *p, uint32_t off, uint32_t val);
|
||||||
|
static void _uvm32_store2(void *p, uint32_t off, uint16_t val);
|
||||||
|
static void _uvm32_store1(void *p, uint32_t off, uint8_t val);
|
||||||
|
static uint32_t _uvm32_load4(void *p, uint32_t off);
|
||||||
|
static uint16_t _uvm32_load2(void *p, uint32_t off);
|
||||||
|
static uint8_t _uvm32_load1(void *p, uint32_t off);
|
||||||
|
static int16_t _uvm32_load2s(void *p, uint32_t off);
|
||||||
|
static int8_t _uvm32_load1s(void *p, uint32_t off);
|
||||||
#endif
|
#endif
|
||||||
#include "mini-rv32ima.h"
|
#include "mini-rv32ima.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue