aboutsummaryrefslogblamecommitdiff
path: root/mips.c
blob: fd41e67a99a86bfe2c0071e69a3e62bb733234de (plain) (tree)
1
2
3
4
5
6
7
8
9

                   

                   




                 
                  










                                    






                                                          
                                                                  

                           
                                                                  





















                                                                                          










                                             
                                      
                             
                                
                               
                           
















                                                                              
                                      
                             




















                                                                          
                                                            

                    
                                        
















                                               

                                
         
                                    






                                                         
                                                 



















                                                
                                          







                                               
                                           






















                                                              

                                




















                                                                  







                                                             





                                             






                                                 


                         

                                                  


                       



                                         








                                                      

                                   


                          
                                                                 






                                                              
                                   























                                                                            
                                                     

                                                               





                                                              

                                                 
                                                          

                                                      













                                                                                      



                                                                     

                                                      








                                                                                    






                                                                       
                                                     
                                                               
                                      
                               




                                                              

















                                                                                         
                                                                            





                                                  


                                                                                      

                                                                                 








                                                                           



                          






                                                                                                  












                                                                            
                                                                  
















































                                                                                 
                                                                          





































                                                                    
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "ast.h"
#include "ssa.h"
#include "mips.h"

int reg_v0 = 2;
int reg_v1 = 3;
COpr_t status[32];

void mips_prologue() {
    CVList_t v;
    CSList_t s;
    printf(".data 0x10000000\n");
    for (v = gvars; v; v = v->next)
    {
        CVar_t var = v->var;
        printf("\t.align 2\n");
        printf("_%s:\n", var->name);
        var->start = -1;
        if (var->initr)
        {
            CNode *initr = var->initr->chd;
            assert(var->initr->rec.subtype == INITR_NORM);
            switch (initr->ext.type->type)
            {
                case CINT:
                    printf("\t.word %ld\n", initr->ext.const_val);
                    break;
                case CCHAR:
                    printf("\t.byte %ld