#include <unistd.h>
#ifndef __linux__
-#include <sys/systeminfo.h>
#include <thread.h>
#endif
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/tokentype.h>
#include <mono/utils/mono-math.h>
+#include <mono/utils/mono-hwcap-sparc.h>
#include "mini-sparc.h"
#include "trace.h"
#endif
-/* Whenever the CPU supports v9 instructions */
-static gboolean sparcv9 = FALSE;
-
/* Whenever this is a 64bit executable */
#if SPARCV9
static gboolean v64 = TRUE;
void
mono_arch_cpu_init (void)
{
- guint32 dummy;
- /* make sure sparcv9 is initialized for embedded use */
- mono_arch_cpu_optimizazions(&dummy);
}
/*
* This function returns the optimizations supported on this cpu.
*/
guint32
-mono_arch_cpu_optimizazions (guint32 *exclude_mask)
+mono_arch_cpu_optimizations (guint32 *exclude_mask)
{
- char buf [1024];
guint32 opts = 0;
*exclude_mask = 0;
-#ifndef __linux__
- if (!sysinfo (SI_ISALIST, buf, 1024))
- g_assert_not_reached ();
-#else
- /* From glibc. If the getpagesize is 8192, we're on sparc64, which
- * (in)directly implies that we're a v9 or better.
- * Improvements to this are greatly accepted...
- * Also, we don't differentiate between v7 and v8. I sense SIGILL
- * sniffing in my future.
- */
- if (getpagesize() == 8192)
- strcpy (buf, "sparcv9");
- else
- strcpy (buf, "sparcv8");
-#endif
-
- /*
+ /*
* On some processors, the cmov instructions are even slower than the
* normal ones...
*/
- if (strstr (buf, "sparcv9")) {
+ if (mono_hwcap_sparc_is_v9)
opts |= MONO_OPT_CMOV | MONO_OPT_FCMOV;
- sparcv9 = TRUE;
- }
else
*exclude_mask |= MONO_OPT_CMOV | MONO_OPT_FCMOV;
return opts;
}
+/*
+ * This function test for all SIMD functions supported.
+ *
+ * Returns a bitmask corresponding to all supported versions.
+ *
+ */
+guint32
+mono_arch_cpu_enumerate_simd_versions (void)
+{
+ /* SIMD is currently unimplemented */
+ return 0;
+}
+
#ifdef __GNUC__
#define flushi(addr) __asm__ __volatile__ ("iflush %0"::"r"(addr):"memory")
#else /* assume Sun's compiler */
*
* Sparcv8 needs a flush every 8 bytes.
*/
- align = (sparcv9 ? 32 : 8);
+ align = (mono_hwcap_sparc_is_v9 ? 32 : 8);
start &= ~(align - 1);
end = (end + (align - 1)) & ~(align - 1);
gboolean
mono_sparc_is_v9 (void) {
- return sparcv9;
+ return mono_hwcap_sparc_is_v9;
}
gboolean
#define EMIT_COND_SYSTEM_EXCEPTION_GENERAL(ins,cond,sexc_name,filldelay,icc) do { \
mono_add_patch_info (cfg, (guint8*)(code) - (cfg)->native_code, \
MONO_PATCH_INFO_EXC, sexc_name); \
- if (sparcv9 && ((icc) != sparc_icc_short)) { \
+ if (mono_hwcap_sparc_is_v9 && ((icc) != sparc_icc_short)) { \
sparc_branchp (code, 0, (cond), (icc), 0, 0); \
} \
else { \
((ins->inst_offset == last_ins->inst_offset - 4)) &&
(ins->inst_imm == 0) &&
(last_ins->inst_imm == 0)) {
- if (sparcv9) {
+ if (mono_hwcap_sparc_is_v9) {
last_ins->opcode = OP_STOREI8_MEMBASE_IMM;
last_ins->inst_offset = ins->inst_offset;
MONO_DELETE_INS (bb, ins);
sparc_branch (code, 0, sparc_be, 0);
/* delay slot */
sparc_set (code, 0, sparc_o7);
- sparc_sub_imm (code, 0, size_reg, sparcv9 ? 8 : 4, size_reg);
+ sparc_sub_imm (code, 0, size_reg, mono_hwcap_sparc_is_v9 ? 8 : 4, size_reg);
/* start of loop */
br [1] = code;
- if (sparcv9)
+ if (mono_hwcap_sparc_is_v9)
sparc_stx (code, sparc_g0, ins->dreg, sparc_o7);
else
sparc_st (code, sparc_g0, ins->dreg, sparc_o7);
sparc_branch (code, 0, sparc_bl, 0);
sparc_patch (br [2], br [1]);
/* delay slot */
- sparc_add_imm (code, 0, sparc_o7, sparcv9 ? 8 : 4, sparc_o7);
+ sparc_add_imm (code, 0, sparc_o7, mono_hwcap_sparc_is_v9 ? 8 : 4, sparc_o7);
sparc_patch (br [0], code);
}
break;
if (offset <= 16) {
i = 0;
while (i < offset) {
- if (sparcv9) {
+ if (mono_hwcap_sparc_is_v9) {
sparc_stx_imm (code, sparc_g0, ins->dreg, i);
i += 8;
}
}
else {
sparc_set (code, offset, sparc_o7);
- sparc_sub_imm (code, 0, sparc_o7, sparcv9 ? 8 : 4, sparc_o7);
+ sparc_sub_imm (code, 0, sparc_o7, mono_hwcap_sparc_is_v9 ? 8 : 4, sparc_o7);
/* beginning of loop */
br [0] = code;
- if (sparcv9)
+ if (mono_hwcap_sparc_is_v9)
sparc_stx (code, sparc_g0, ins->dreg, sparc_o7);
else
sparc_st (code, sparc_g0, ins->dreg, sparc_o7);
br [1] = code;
sparc_branch (code, 0, sparc_bne, 0);
/* delay slot */
- sparc_sub_imm (code, 0, sparc_o7, sparcv9 ? 8 : 4, sparc_o7);
+ sparc_sub_imm (code, 0, sparc_o7, mono_hwcap_sparc_is_v9 ? 8 : 4, sparc_o7);
sparc_patch (br [1], br [0]);
}
}
case OP_IBGE_UN:
case OP_IBLE:
case OP_IBLE_UN: {
- if (sparcv9)
+ if (mono_hwcap_sparc_is_v9)
EMIT_COND_BRANCH_PREDICTED (ins, opcode_to_sparc_cond (ins->opcode), 1, 1);
else
EMIT_COND_BRANCH (ins, opcode_to_sparc_cond (ins->opcode), 1, 1);
}
void
-mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, MonoCodeManager *dyn_code_mp, gboolean run_cctors)
{
MonoJumpInfo *patch_info;
while (cfg->code_len + max_epilog_size > (cfg->code_size - 16)) {
cfg->code_size *= 2;
cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
- mono_jit_stats.code_reallocs++;
+ cfg->stat_code_reallocs++;
}
code = (guint32*)(cfg->native_code + cfg->code_len);
while (cfg->code_len + code_size > (cfg->code_size - 16)) {
cfg->code_size *= 2;
cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
- mono_jit_stats.code_reallocs++;
+ cfg->stat_code_reallocs++;
}
code = (guint32*)(cfg->native_code + cfg->code_len);
#endif
void
-mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
+mono_arch_tls_init (void)
{
+ MonoJitTlsData *jit_tls;
+
if (!lmf_addr_key_inited) {
int res;
}
+ jit_tls = mono_get_jit_tls ();
+
#ifdef MONO_SPARC_THR_TLS
- thr_setspecific (lmf_addr_key, &tls->lmf);
+ thr_setspecific (lmf_addr_key, &jit_tls->lmf);
#else
- pthread_setspecific (lmf_addr_key, &tls->lmf);
+ pthread_setspecific (lmf_addr_key, &jit_tls->lmf);
#endif
}
+void
+mono_arch_finish_init (void)
+{
+}
+
void
mono_arch_free_jit_tls_data (MonoJitTlsData *tls)
{
* Returns the size of the activation frame.
*/
int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
{
int k, align;
CallInfo *cinfo;
return 0;
}
-MonoInst* mono_arch_get_domain_intrinsic (MonoCompile* cfg)
-{
- return NULL;
-}
-
-gpointer
+mgreg_t
mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
{
/* FIXME: implement */
g_assert_not_reached ();
}
+
+gboolean
+mono_arch_opcode_supported (int opcode)
+{
+ return FALSE;
+}