dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/engine md_ia64.c, NONE, 1.1 md_ia64.h, N


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine md_ia64.c, NONE, 1.1 md_ia64.h, NONE, 1.1 md_ia64_macros.h, NONE, 1.1 Makefile.am, 1.64, 1.65 cvm.c, 1.45, 1.46 cvm_config.h, 1.9, 1.10 cvmc_setup.c, 1.36, 1.37 unroll.c, 1.8, 1.9 unroll_arith.c, 1.3, 1.4
Date: Sat, 09 Aug 2003 22:12:00 -0400

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv31673/engine

Modified Files:
        Makefile.am cvm.c cvm_config.h cvmc_setup.c unroll.c 
        unroll_arith.c 
Added Files:
        md_ia64.c md_ia64.h md_ia64_macros.h 
Log Message:


Initial version of the ia64 unroller.


--- NEW FILE ---
/*
 * md_ia64.h - Machine-dependent definitions of IA-64
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * Contributed by : CH Gowri Kumar <address@hidden>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "cvm_config.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef CVM_IA64

#include "md_ia64_macros.h"

int soi,sol,soo,sor;
unsigned long int instr0,instr1,instr2,template;

static void MessageBox(char* msg1,char* msg2)
{
        int sw,tw,bw,lm,tw1,tw2;
        int i;
        
        sw = 80;
        tw1 = strlen(msg1);
        tw2 = strlen(msg2);
        tw = (tw1>tw2)?tw1:tw2;
        bw = tw+6;
        lm = (sw-bw)/2;

        printf("\n");
        for(i = 0;i < lm; i++)
                printf(" ");
        
        printf("+");
        
        for(i = 0;i < (bw-2); i++)
                printf("-");
        
        printf("+\n");
        
        for(i = 0;i < lm;i++)
                printf(" ");
        
        printf("|  ");
        
        for(i = 0;i < tw;i++)
                printf(" ");
        printf("  |\n");

        for(i = 0;i < lm; i++)
                printf(" ");
        
        printf("|  ");
        printf("%s",msg1);
        
        for(i = 0;i < (tw-tw1);i++)
                printf(" ");
        printf("  |\n");
        

        for(i = 0;i < lm; i++)
                printf(" ");
        
        printf("|  ");
        printf("%s",msg2);
        for(i = 0;i < (tw-tw2);i++)
                printf(" ");
        printf("  |\n");

        for(i = 0;i < lm; i++)
                printf(" ");
        
        printf("|  ");
        for(i = 0;i < tw; i++)
                printf(" ");
        printf("  |\n");

        for(i = 0;i < lm; i++)
                printf(" ");
        printf("+");
        for(i = 0;i < (bw-2); i++)
                printf("-");
        printf("+\n");
}
        
void IA64_DebugMessageBox(char* msg,char *file,int line,char *function)
{
#define SIZE 80
#define FANCY
#if defined(FANCY)
        char msg1[SIZE];
        char msg2[SIZE];
        msg1[SIZE-1] = '\0';
        msg2[SIZE-1] = '\0';
        snprintf(msg1,SIZE-1,"%s: In function `%s'",file,function);
        snprintf(msg2,SIZE-1,"%s:%d: %s is not implemented",file,line,msg);
        MessageBox(msg1,msg2);
#else
        fprintf(stderr,"%s: In function `%s':\n",file,function);
        fprintf(stderr,"%s:%d: %s\n",file,line,msg);
#endif
        exit(0);

}

int IA64_Error(char* msg,char *file,int line,char *function)
{
        fprintf(stderr,"%s: In function `%s':\n",file,function);
        fprintf(stderr,"%s:%d: %s\n",file,line,msg);
        abort();
        return 0;
}

int IA64_Dummy()
{
        return 0;
}

int IA64_Execute(Bundle *code)
{
        
        IA64_FUNCTION *fp,newfp;
        int (*pSubRoutine)(void);
        int i;
        
        fp = (IA64_FUNCTION*)IA64_Dummy;
        newfp.gp = fp->gp;
        newfp.addr = (long)code;
        pSubRoutine = (int(*)(void))&newfp;

        /* Make the page containing the code  executable */
        mprotect((void *) ((long) code & ~(getpagesize () - 1)),
                                     getpagesize(), PROT_READ | PROT_WRITE | 
PROT_EXEC);
        
        IA64_FlushCache(code,CODESIZE);
        i = (*pSubRoutine)();
        
        return i;
}


void IA64_FlushCache(void *addr,unsigned long len)
{
        void *end = (char*)addr + len;
        while(addr < end)
        {
                asm volatile("fc %0" :: "r"(addr));
                addr = (char*)addr + 32;
        }
        asm volatile(";;sync.i;;srlz.i;;");
}

Bundle ALLOC_rilor(int r1,int i,int l,int o,int r)
{
        Bundle b;
        Bundle* a;
        UL instr0,instr1,instr2;
        int sol,sor,sof;
        
        a = &b;
        
        sof = i+l+o;
        sol = i+l;
        sor = r>>3;

        assert(sof<=96);
        assert(sor<=sof);
        assert(sol<=sof);

        instr0 = ALLOC_rarpfsilor(0,r1,IA64_AR_PFS,i,l,o,r);
        instr1 = NOP_M_imm21(0,0);
        instr2 = NOP_I_imm21(0,0);
        MAKE_BUNDLE(a,M_MI_,instr0,instr1,instr2);
        return b;
}

Bundle BRL_imm64(Bundle* inst,int qp,UL label)
{
        UL target64;
        UL imm39,imm20b;
        int template,sign;
        Bundle *a,b;
        
        target64 = (UL)inst - label;
        target64 = target64 >> 4;
        
        sign = MASK(1) & (target64 >>59);
        imm39 = MASK(39) & (target64>>20);
        imm20b = MASK(20) & (target64);

        template = MLX_;
        instr0 = NOP_M_imm21(IA64_P0,0);
        instr1 = imm39 << 2;
        instr2 = B1(0X0C,sign,0,0,imm20b,0,0,0,qp);
        a = &b;
        MAKE_BUNDLE(a,template,instr0,instr1,instr2);
        return b;
        
                
}
        
Bundle MOVL_rimm64(int qp,int r1,UL imm64)
{
        UL instr0,instr1,instr2;
        UL target23,target41;
        Bundle b;
        Bundle* a;
        int template;
        int sign;
        
        sign = MASK(1) &(imm64>>63);
        target23 = ((imm64)&MASK(22));
        target23 = target23 | sign<<22;
        target41 = (imm64>>22)&MASK(41);
        
        template = MLX_;
        instr0 = NOP_M_imm21(IA64_P0,0);
        instr1 = target41;
        instr2 = MOVL_rimm23(qp,r1,target23);
        a = &b;
        MAKE_BUNDLE(a,template,instr0,instr1,instr2);
        return b;
}

void IA64_AddInstruction(Bundle* bundle,IA64Units unit,UL instr)
{
        UL instr0,instr1,instr2;
        int template;
        
        instr0=instr1=instr2=template=0;
        switch(unit)
        {
                case IA64_AUNIT:
                        template = MII_;
                        instr0 = NOP_M_imm21(IA64_P0,0);
                        instr1 = NOP_I_imm21(IA64_P0,0);
                        instr2 = instr;
                        break;
                        
                case IA64_IUNIT:
                        template = MII_;
                        instr0 = NOP_M_imm21(IA64_P0,0);
                        instr1 = NOP_I_imm21(IA64_P0,0);
                        instr2 = instr;
                   break;       

                case IA64_MUNIT:
                        template = MII_;
                        instr0 = instr;
                        instr1 = NOP_I_imm21(IA64_P0,0);
                        instr2 = NOP_I_imm21(IA64_P0,0);
                        break;

                case IA64_BUNIT:
                        template = MFB_;
                        instr0 = NOP_M_imm21(IA64_P0,0);
                        instr1 = NOP_F_imm21(IA64_P0,0);
                        instr2 = instr;
                   break;       
                   
                case IA64_FUNIT:
                        template = MFB_;
                        instr0 = NOP_M_imm21(IA64_P0,0);
                        instr1 = instr;
                        instr2 = NOP_B_imm21(IA64_P0,0);
                        break;
                case IA64_XUNIT:
                        printf("X-UNIT Not Yet Implemented\n");
                        assert(0);
                   break;       
        }
        bundle->a =(template)|(instr0<<5) | ((instr1&MASK(18))<<46);\
        bundle->b =(instr1>>18)|(instr2 << 23);
}

void IA64_DumpCode(unsigned char *start, int len)
{
        char cmdline[128];
        FILE *file = fopen("/tmp/unroll.s", "w");
        if(!file)
        {
                return;
        }
        while(len > 0)
        {
                fprintf(file, ".byte %d\n", (int)(*start));
                ++start;
                --len;
        }
        fclose(file);
        sprintf(cmdline, "as /tmp/unroll.s -o /tmp/unroll.o;objdump 
--adjust-vma=%ld -d /tmp/unroll.o", (long)start);
        system(cmdline);
        unlink("/tmp/unroll.s");
        unlink("/tmp/unroll.o");
        putc('\n', stdout);
        fflush(stdout);
}

#endif /* CVM_IA64 */

#ifdef __cplusplus
};
#endif

--- NEW FILE ---
/*
 * md_ia64.h - Machine-dependent definitions of IA-64
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * Contributed by :CH Gowri Kumar <address@hidden>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
[...1238 lines suppressed...]
#define md_store_memindex_sbyte(inst,reg,basereg,indexreg,disp) \
        dmesg("md_store_memindex_sbyte")

/*
 * Store a short value into an indexed array.
 */
#define md_store_memindex_short(inst,reg,basereg,indexreg,disp) \
        dmesg("md_store_memindex_short")

/*
 * Store an unsigned short value into an indexed array.
 */
#define md_store_memindex_ushort(inst,reg,basereg,indexreg,disp)        \
        dmesg("md_store_memindex_ushort")

#ifdef  __cplusplus
};
#endif

#endif /* _ENGINE_MD_IA-64_H */

--- NEW FILE ---
/*
 * md_ia64_macros.h - Code generation macros for the Itanium processor
 * 
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 * 
 * Contributed by :CH Gowri Kumar <address@hidden>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
[...6374 lines suppressed...]
typedef Bundle* ia64_inst_ptr;
Bundle MOVL_rimm64(int,int,UL);
Bundle BRL_imm64(Bundle*,int,UL);
Bundle ALLOC_rilor(int r1,int i,int l,int o,int r);
void IA64_FlushCache(void *addr, unsigned long len);
void IA64_AddInstruction(Bundle*,IA64Units unit,unsigned long instr);
void IA64_DumpCode(unsigned char*,int);
int  IA64_Error(char*,char*,int,char*);
int  IA64_Execute(Bundle* code);
int  IA64_Dummy();
void  IA64_DebugMessageBox(char*,char*,int,char*);

extern int soi,sol,soo,sor;
extern unsigned long instr0,instr1,instr2,template;

#ifdef __cplusplus
};
#endif

#endif /* _MD_IA64_MACROS_H */

Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/Makefile.am,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -r1.64 -r1.65
*** Makefile.am 28 Jul 2003 03:56:24 -0000      1.64
--- Makefile.am 10 Aug 2003 02:11:58 -0000      1.65
***************
*** 56,59 ****
--- 56,60 ----
                                                md_x86.c \
                                                md_arm.c \
+                                               md_ia64.c \
                                                verify.c
  

Index: cvm.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -r1.45 -r1.46
*** cvm.c       18 Jul 2003 05:36:04 -0000      1.45
--- cvm.c       10 Aug 2003 02:11:58 -0000      1.46
***************
*** 99,102 ****
--- 99,111 ----
      #define IL_MEMSET(dst,ch,len)           (ILMemSet((dst), (ch), (len)))
      #define IL_MEMCMP(dst,src,len)          (ILMemCmp((dst), (src), (len)))
+ #elif defined(CVM_IA64) && defined(__GNUC__) && !defined(IL_NO_ASM)
+     #define REGISTER_ASM_PC(x)              register x asm ("r4")
+     #define REGISTER_ASM_STACK(x)           register x asm ("r5")
+     #define REGISTER_ASM_FRAME(x)           register x asm ("r6")
+       #define IL_MEMCPY(dst,src,len)                  (ILMemCpy((dst), (src), 
(len)))
+       #define IL_MEMMOVE(dst,src,len)                 (ILMemMove((dst), 
(src), (len)))
+       #define IL_MEMZERO(dst,len)                             
(ILMemZero((dst), (len)))
+       #define IL_MEMSET(dst,ch,len)                   (ILMemSet((dst), (ch), 
(len)))
+       #define IL_MEMCMP(dst,src,len)                  (ILMemCmp((dst), (src), 
(len)))
  #else
      #define REGISTER_ASM_PC(x)              x

Index: cvm_config.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_config.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** cvm_config.h        22 Jul 2003 23:05:37 -0000      1.9
--- cvm_config.h        10 Aug 2003 02:11:58 -0000      1.10
***************
*** 92,95 ****
--- 92,98 ----
        #define CVM_PPC
  #endif
+ #if defined(__ia64) || defined(__ia64__)
+       #define CVM_IA64
+ #endif
  
  /*
***************
*** 186,190 ****
        !defined(IL_CVM_PROFILE_CVM_VAR_USAGE) && \
        defined(IL_CONFIG_UNROLL)
- #define       IL_CVM_DIRECT_UNROLLED_X86
  #define       IL_CVM_DIRECT_UNROLLED
  #undef        IL_CVM_FLAVOUR
--- 189,192 ----
***************
*** 196,203 ****
        !defined(IL_CVM_PROFILE_CVM_VAR_USAGE) && \
        defined(IL_CONFIG_UNROLL)
- #define       IL_CVM_DIRECT_UNROLLED_ARM
  #define       IL_CVM_DIRECT_UNROLLED
  #undef        IL_CVM_FLAVOUR
  #define       IL_CVM_FLAVOUR "Direct Unrolled (ARM)"
  #endif
  
--- 198,215 ----
        !defined(IL_CVM_PROFILE_CVM_VAR_USAGE) && \
        defined(IL_CONFIG_UNROLL)
  #define       IL_CVM_DIRECT_UNROLLED
  #undef        IL_CVM_FLAVOUR
  #define       IL_CVM_FLAVOUR "Direct Unrolled (ARM)"
+ #endif
+ #if 0 /* remove this once ia64 unroller is finished */
+ #if defined(IL_CVM_DIRECT) && defined(CVM_IA64) && \
+       defined(__GNUC__) && !defined(IL_NO_ASM) && \
+       !defined(IL_CVM_PROFILE_CVM_METHODS) && \
+       !defined(IL_CVM_PROFILE_CVM_VAR_USAGE) && \
+       defined(IL_CONFIG_UNROLL)
+ #define       IL_CVM_DIRECT_UNROLLED
+ #undef        IL_CVM_FLAVOUR
+ #define       IL_CVM_FLAVOUR "Direct Unrolled (ia64)"
+ #endif
  #endif
  

Index: cvmc_setup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_setup.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** cvmc_setup.c        28 Jul 2003 03:56:24 -0000      1.36
--- cvmc_setup.c        10 Aug 2003 02:11:58 -0000      1.37
***************
*** 20,23 ****
--- 20,24 ----
  
  #ifdef IL_CVMC_CODE
+ /*#define DONT_UNROLL_SYSTEM */
  
  /*
***************
*** 243,247 ****
        ILType *type;
  
- 
        /* Determine where the new method will start output within the buffer */
        if(newStart)
--- 244,247 ----
***************
*** 348,356 ****
        }
  
!       /* Mark this method as perhaps needing to be unrolled later */
!       if(ordinaryMethod && _ILCVMUnrollPossible() && !(coder->debugEnabled))
        {
!               CVMP_OUT_NONE(COP_PREFIX_UNROLL_METHOD);
        }
  
        /* Output CVM code to allocate space for the local variables */
--- 348,367 ----
        }
  
! #if defined(DONT_UNROLL_SYSTEM)
! {
!       const char *assemName;
!       assemName = ILImageGetAssemblyName(ILProgramItem_Image(method));
!       if(strcmp(assemName,"mscorlib") != 0 && strcmp(assemName,"I18N") != 0)
        {
! #endif
!               /* Mark this method as perhaps needing to be unrolled later */
!               if(ordinaryMethod && _ILCVMUnrollPossible() && 
!(coder->debugEnabled))
!               {
!                       CVMP_OUT_NONE(COP_PREFIX_UNROLL_METHOD);
!               }
! #if defined(DONT_UNROLL_SYSTEM)
        }
+ }
+ #endif
  
        /* Output CVM code to allocate space for the local variables */

Index: unroll.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/unroll.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** unroll.c    12 Jul 2003 06:01:17 -0000      1.8
--- unroll.c    10 Aug 2003 02:11:58 -0000      1.9
***************
*** 40,43 ****
--- 40,45 ----
  #elif defined(CVM_ARM)
        #include "md_arm.h"
+ #elif defined(CVM_IA64)
+       #include "md_ia64.h"
  #else
        #error "Unknown unroller platform"

Index: unroll_arith.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/unroll_arith.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** unroll_arith.c      12 Jul 2003 06:01:17 -0000      1.3
--- unroll_arith.c      10 Aug 2003 02:11:58 -0000      1.4
***************
*** 239,243 ****
        GetTopTwoWordRegisters(&unroll, &reg, &reg2,
                                                   MD_REG1_NATIVE | 
MD_REG2_NATIVE);
!       md_add_reg_reg_word_native(unroll.out, reg, reg2);
        FreeTopRegister(&unroll, -1);
  #endif
--- 239,243 ----
        GetTopTwoWordRegisters(&unroll, &reg, &reg2,
                                                   MD_REG1_NATIVE | 
MD_REG2_NATIVE);
!       md_and_reg_reg_word_native(unroll.out, reg, reg2);
        FreeTopRegister(&unroll, -1);
  #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]