From e92937676ca1b9a06012f4004da60b7cfef002bb Mon Sep 17 00:00:00 2001 From: Neale Ferguson Date: Tue, 17 Mar 2015 10:35:21 -0400 Subject: [PATCH] s390x-codegen.h : Fix instruction definition and add instruction format variant mini-s390x.h : Enable profile coverage suport-s390x.h : Add processor facility definitions --- mono/arch/s390x/s390x-codegen.h | 12 +++++- mono/mini/mini-s390x.c | 22 ++++------ mono/mini/support-s390x.h | 93 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 16 deletions(-) diff --git a/mono/arch/s390x/s390x-codegen.h b/mono/arch/s390x/s390x-codegen.h index ae4bcdd190e..8c9244d3333 100644 --- a/mono/arch/s390x/s390x-codegen.h +++ b/mono/arch/s390x/s390x-codegen.h @@ -614,6 +614,14 @@ typedef struct { (opc & 0xff))); \ } while (0) +#define S390_SIY_1(c,opc,d1,b1,i2) do \ +{ \ + s390_emit16(c, ((opc & 0xff00) | i2)); \ + s390_emit32(c, ((b1) << 28 | (((d1) & 0xfff) << 16) | \ + ((((d1) & 0xff000) >> 12) << 8) | \ + (opc & 0xff))); \ +} while (0) + #define S390_S(c,opc,s2,p2) s390_emit32(c, (opc << 16 | (s2) << 12 | ((p2) & 0xfff))) #define S390_SS_1(c,opc,ln,s1,p1,s2,p2) do \ @@ -691,13 +699,13 @@ typedef struct { #define s390_algfr(c, r1, r2) S390_RRE(c, 0xb91a, r1, r2) #define s390_alghsik(c, r, v) S390_RIE_1(c, 0xecd8, r, v) #define s390_algr(c, r1, r2) S390_RRE(c, 0xb90a, r1, r2) -#define s390_algsi(c, r, v) S390_SIY(c, 0xeb7e, r, v) +#define s390_algsi(c, d1, b1, i2) S390_SIY_1(c, 0xeb7e, d1, b1, i2) #define s390_alhhhr(c, r1, r2, r3) S390_RRF_1(c, 0xb9ca, r1, r2, r3) #define s390_alhhlr(c, r1, r2, r3) S390_RRF_1(c, 0xb9da, r1, r2, r3) #define s390_alhsik(c, r, v) S390_RIE_1(c, 0xecda, r, v) #define s390_alr(c, r1, r2) S390_RR(c, 0x1e, r1, r2) #define s390_alrk(c, r1, r2) S390_RRF(c, 0xb9fa, r1, r2) -#define s390_alsi(c, r, v) S390_SIY(c, 0xeb6e, r, v) +#define s390_alsi(c, d1, b1, i2) S390_SIY_1(c, 0xeb6e, d1, b1, i2) #define s390_alsih(c, r, v) S390_RIL_1(c, 0xcca, r, v) #define s390_alsihn(c, r, v) S390_RIL_1(c, 0xccb, r, v) #define s390_aly(c, r, x, b, d) S390_RXY(c, 0xe35e, r, x, b, d) diff --git a/mono/mini/mini-s390x.c b/mono/mini/mini-s390x.c index 3676ab578b7..004540fb7e2 100644 --- a/mono/mini/mini-s390x.c +++ b/mono/mini/mini-s390x.c @@ -2926,24 +2926,20 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) guint offset; guint8 *code = cfg->native_code + cfg->code_len; guint last_offset = 0; - int max_len, cpos, src2; + int max_len, src2; /* we don't align basic blocks of loops on s390 */ if (cfg->verbose_level > 2) g_print ("Basic block %d starting at offset 0x%x\n", bb->block_num, bb->native_offset); - cpos = bb->max_offset; - - if (cfg->prof_options & MONO_PROFILE_COVERAGE) { - //MonoCoverageInfo *cov = mono_get_coverage_info (cfg->method); - //g_assert (!mono_compile_aot); - //cpos += 6; - //if (bb->cil_code) - // cov->data [bb->dfn].iloffset = bb->cil_code - cfg->cil_code; - /* this is not thread save, but good enough */ - /* fixme: howto handle overflows? */ - //x86_inc_mem (code, &cov->data [bb->dfn].count); + if ((cfg->prof_options & MONO_PROFILE_COVERAGE) && cfg->coverage_info) { + MonoProfileCoverageInfo *cov = cfg->coverage_info; + g_assert (!mono_compile_aot); + cov->data [bb->dfn].cil_code = bb->cil_code; + /* This is not thread save, but good enough */ + S390_SET (code, s390_r1, &cov->data [bb->dfn].count); + s390_alsi (code, 0, s390_r1, 1); } MONO_BB_FOR_EACH_INS (bb, ins) { @@ -4613,8 +4609,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) g_assert_not_reached (); } - cpos += max_len; - last_offset = offset; } diff --git a/mono/mini/support-s390x.h b/mono/mini/support-s390x.h index f93dc88c0c6..4c4b7d32f76 100644 --- a/mono/mini/support-s390x.h +++ b/mono/mini/support-s390x.h @@ -1,6 +1,99 @@ #ifndef __MONO_SUPPORT_S390X_H__ #define __MONO_SUPPORT_S390X_H__ +typedef struct __FACLIST__ { + uint8_t n3:1; // 000 - N3 instructions + uint8_t zi:1; // 001 - z/Arch installed + uint8_t za:1; // 002 - z/Arch active + uint8_t date:1; // 003 - DAT-enhancement + uint8_t idtes:1; // 004 - IDTE-segment tables + uint8_t idter:1; // 005 - IDTE-region tables + uint8_t asnlx:1; // 006 - ASN-LX reuse + uint8_t stfle:1; // 007 - STFLE + uint8_t edat1:1; // 008 - EDAT 1 + uint8_t srs:1; // 009 - Sense-Running-Status + uint8_t csske:1; // 010 - Conditional SSKE + uint8_t ctf:1; // 011 - Configuration-topology + uint8_t ibm01:1; // 012 - Assigned to IBM + uint8_t ipter:1; // 013 - IPTE-range + uint8_t nqks:1; // 014 - Nonquiescing key-setting + uint8_t ibm02:1; // 015 - Assigned to IBM + uint8_t etf2:1; // 016 - Extended translation 2 + uint8_t msa:1; // 017 - Message security assist 1 + uint8_t ld:1; // 018 - Long displacement + uint8_t ldh:1; // 019 - Long displacement high perf + uint8_t mas:1; // 020 - HFP multiply-add-subtract + uint8_t eif:1; // 021 - Extended immediate + uint8_t etf3:1; // 022 - Extended translation 3 + uint8_t hux:1; // 023 - HFP unnormalized extension + uint8_t etf2e:1; // 024 - Extended translation enhanced 2 + uint8_t stckf:1; // 025 - Store clock fast + uint8_t pe:1; // 026 - Parsing enhancement + uint8_t mvcos:1; // 027 - Move with optional specs + uint8_t tods:1; // 028 - TOD steering + uint8_t x000:1; // 029 - Undefined + uint8_t etf3e:1; // 030 - ETF3 enhancement + uint8_t ecput:1; // 031 - Extract CPU time + uint8_t csst:1; // 032 - Compare swap and store + uint8_t csst2:1; // 033 - Compare swap and store 2 + uint8_t gie:1; // 034 - General instructions extension + uint8_t ee:1; // 035 - Execute extensions + uint8_t em:1; // 036 - Enhanced monitor + uint8_t fpe:1; // 037 - Floating point extension + uint8_t x001:1; // 038 - Undefined + uint8_t ibm03:1; // 039 - Assigned to IBM + uint8_t spp:1; // 040 - Set program parameters + uint8_t fpse:1; // 041 - FP support enhancement + uint8_t dfp:1; // 042 - DFP + uint8_t dfph:1; // 043 - DFP high performance + uint8_t pfpo:1; // 044 - PFPO instruction + uint8_t multi:1; // 045 - Multiple inc load/store on CC 1 + uint8_t ibm04:1; // 046 - Assigned to IBM + uint8_t cmpsce:1; // 047 - CMPSC enhancement + uint8_t dfpzc:1; // 048 - DFP zoned conversion + uint8_t misc:1; // 049 - Multiple inc load and trap + uint8_t ctx:1; // 050 - Constrained transactional-execution + uint8_t ltlb:1; // 051 - Local TLB clearing + uint8_t ia:1; // 052 - Interlocked access + uint8_t lsoc2:1; // 053 - Load/store on CC 2 + uint8_t x002:1; // 054 - Undefined + uint8_t ibm05:1; // 055 - Assigned to IBM + uint8_t x003:1; // 056 - Undefined + uint8_t msa5:1; // 057 - Message security assist 5 + uint8_t x004:1; // 058 - Undefined + uint8_t x005:1; // 059 - Undefined + uint8_t x006:1; // 060 - Undefined + uint8_t x007:1; // 061 - Undefined + uint8_t ibm06:1; // 062 - Assigned to IBM + uint8_t x008:1; // 063 - Undefined + uint8_t x009:1; // 064 - Undefined + uint8_t ibm07:1; // 065 - Assigned to IBM + uint8_t rrbm:1; // 066 - Reset reference bits multiple + uint8_t cmc:1; // 067 - CPU measurement counter + uint8_t cms:1; // 068 - CPU Measurement sampling + uint8_t ibm08:1; // 069 - Assigned to IBM + uint8_t ibm09:1; // 070 - Assigned to IBM + uint8_t ibm10:1; // 071 - Assigned to IBM + uint8_t ibm11:1; // 072 - Assigned to IBM + uint8_t txe:1; // 073 - Transactional execution + uint8_t sthy:1; // 074 - Store hypervisor information + uint8_t aefsi:1; // 075 - Access exception fetch/store indication + uint8_t msa3:1; // 076 - Message security assist 3 + uint8_t msa4:1; // 077 - Message security assist 4 + uint8_t edat2:1; // 078 - Enhanced DAT 2 + uint8_t x010:1; // 079 - Undefined + uint8_t dfppc:1; // 080 - DFP packed conversion + uint8_t x011:7; // 081-87 - Undefined + uint8_t x012[5]; // 088-127 - Undefined + uint8_t ibm12:1; // 128 - Assigned to IBM + uint8_t vec:1; // 129 - Vector facility + uint8_t x013:6; // 130-135 - Undefined + uint8_t x014:6; // 136-141 - Undefined + uint8_t sccm:1; // 142 - Store CPU counter multiple + uint8_t ibm13:1; // 143 - Assigned to IBM + uint8_t x015[14]; // 144-256 Undefined +} __attribute__ ((packed)) __attribute__ ((aligned(8))) facilities_t; + #define S390_SET(loc, dr, v) \ do { \ guint64 val = (guint64) v; \ -- 2.11.4.GIT