mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-22 16:29:11 +00:00
move pragma code to a separate file
This commit is contained in:
parent
a9ac8da693
commit
aa1c71d17e
@ -414,6 +414,8 @@ m32r*-*-*)
|
||||
m68k-*-*)
|
||||
extra_headers=math-68881.h
|
||||
extra_options="${extra_options} m68k/m68k-tables.opt"
|
||||
c_target_objs="m68k-mac-pragmas.o"
|
||||
cxx_target_objs="m68k-mac-pragmas.o"
|
||||
;;
|
||||
microblaze*-*-*)
|
||||
cpu_type=microblaze
|
||||
|
111
gcc/gcc/config/m68k/m68k-mac-pragmas.c
Normal file
111
gcc/gcc/config/m68k/m68k-mac-pragmas.c
Normal file
@ -0,0 +1,111 @@
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "tm.h"
|
||||
#include "tree.h"
|
||||
|
||||
#include "c-family/c-pragma.h"
|
||||
#include "c-family/c-common.h"
|
||||
#include "diagnostic-core.h"
|
||||
#include "cpplib.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
std::map<std::string, int> pragma_parameter_register_names;
|
||||
extern std::map< std::string, std::vector<int> > pragma_parameter_directives;
|
||||
|
||||
|
||||
static int lookup_reg(std::string s)
|
||||
{
|
||||
std::map<std::string, int>::const_iterator p = pragma_parameter_register_names.find(s);
|
||||
if(p == pragma_parameter_register_names.end())
|
||||
return -1;
|
||||
return p->second;
|
||||
}
|
||||
|
||||
static void
|
||||
m68k_pragma_parameter (cpp_reader * reader ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* on off */
|
||||
tree token;
|
||||
enum cpp_ttype type;
|
||||
|
||||
std::string name;
|
||||
std::vector<int> argregs;
|
||||
|
||||
type = pragma_lex (&token);
|
||||
argregs.push_back(0);
|
||||
if (type == CPP_NAME)
|
||||
{
|
||||
name = IDENTIFIER_POINTER(token);
|
||||
type = pragma_lex (&token);
|
||||
if (type == CPP_NAME)
|
||||
{
|
||||
argregs.back() = lookup_reg(name);
|
||||
if(argregs.back() < 0)
|
||||
{
|
||||
error ("invalid register name %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
name = IDENTIFIER_POINTER(token);
|
||||
type = pragma_lex (&token);
|
||||
}
|
||||
if (type == CPP_EOF)
|
||||
{
|
||||
pragma_parameter_directives[name] = argregs;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == CPP_OPEN_PAREN)
|
||||
{
|
||||
type = pragma_lex (&token);
|
||||
while(argregs.size() == 1 ? type == CPP_NAME : type == CPP_COMMA)
|
||||
{
|
||||
if(argregs.size() != 1)
|
||||
type = pragma_lex (&token);
|
||||
if(type != CPP_NAME)
|
||||
break;
|
||||
|
||||
argregs.push_back(lookup_reg(IDENTIFIER_POINTER(token)));
|
||||
if(argregs.back() < 0)
|
||||
{
|
||||
error ("invalid register name %s", IDENTIFIER_POINTER(token));
|
||||
return;
|
||||
}
|
||||
|
||||
type = pragma_lex (&token);
|
||||
}
|
||||
|
||||
if (type == CPP_CLOSE_PAREN)
|
||||
{
|
||||
type = pragma_lex (&token);
|
||||
if (type != CPP_EOF)
|
||||
{
|
||||
error ("junk at end of #pragma parameter");
|
||||
}
|
||||
else
|
||||
{
|
||||
pragma_parameter_directives[name] = argregs;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
error ("malformed #pragma parameter ");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
m68k_register_pragmas()
|
||||
{
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
std::string n(1, '0' + i);
|
||||
pragma_parameter_register_names["__D" + n] = i;
|
||||
pragma_parameter_register_names["__A" + n] = i + 8;
|
||||
}
|
||||
c_register_pragma (NULL, "parameter", m68k_pragma_parameter);
|
||||
|
||||
}
|
@ -49,17 +49,13 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "opts.h"
|
||||
#include "optabs.h"
|
||||
|
||||
#include "c-family/c-pragma.h"
|
||||
#include "c-family/c-common.h"
|
||||
#include "diagnostic-core.h"
|
||||
#include "cpplib.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
static std::map<std::string, int> pragma_parameter_register_names;
|
||||
static std::map< std::string, std::vector<int> > pragma_parameter_directives;
|
||||
std::map< std::string, std::vector<int> > pragma_parameter_directives;
|
||||
|
||||
|
||||
enum reg_class regno_reg_class[] =
|
||||
@ -1514,7 +1510,7 @@ void m68k_init_cumulative_args (CUMULATIVE_ARGS *cum,
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
int
|
||||
m68k_is_pascal_func(tree fntype, tree fndecl)
|
||||
{
|
||||
if(!fntype)
|
||||
@ -6733,99 +6729,5 @@ m68k_write_macsbug_name(FILE *file, const char *name)
|
||||
|
||||
|
||||
|
||||
static int lookup_reg(std::string s)
|
||||
{
|
||||
std::map<std::string, int>::const_iterator p = pragma_parameter_register_names.find(s);
|
||||
if(p == pragma_parameter_register_names.end())
|
||||
return -1;
|
||||
else
|
||||
return p->second;
|
||||
}
|
||||
|
||||
static void
|
||||
m68k_pragma_parameter (cpp_reader * reader ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* on off */
|
||||
tree token;
|
||||
enum cpp_ttype type;
|
||||
|
||||
std::string name;
|
||||
std::vector<int> argregs;
|
||||
|
||||
type = pragma_lex (&token);
|
||||
argregs.push_back(0);
|
||||
if (type == CPP_NAME)
|
||||
{
|
||||
name = IDENTIFIER_POINTER(token);
|
||||
type = pragma_lex (&token);
|
||||
if (type == CPP_NAME)
|
||||
{
|
||||
argregs.back() = lookup_reg(name);
|
||||
if(argregs.back() < 0)
|
||||
{
|
||||
error ("invalid register name %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
name = IDENTIFIER_POINTER(token);
|
||||
type = pragma_lex (&token);
|
||||
}
|
||||
if (type == CPP_EOF)
|
||||
{
|
||||
pragma_parameter_directives[name] = argregs;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == CPP_OPEN_PAREN)
|
||||
{
|
||||
type = pragma_lex (&token);
|
||||
while(argregs.size() == 1 ? type == CPP_NAME : type == CPP_COMMA)
|
||||
{
|
||||
if(argregs.size() != 1)
|
||||
type = pragma_lex (&token);
|
||||
if(type != CPP_NAME)
|
||||
break;
|
||||
|
||||
argregs.push_back(lookup_reg(IDENTIFIER_POINTER(token)));
|
||||
if(argregs.back() < 0)
|
||||
{
|
||||
error ("invalid register name %s", IDENTIFIER_POINTER(token));
|
||||
return;
|
||||
}
|
||||
|
||||
type = pragma_lex (&token);
|
||||
}
|
||||
|
||||
if (type == CPP_CLOSE_PAREN)
|
||||
{
|
||||
type = pragma_lex (&token);
|
||||
if (type != CPP_EOF)
|
||||
{
|
||||
error ("junk at end of #pragma parameter");
|
||||
}
|
||||
else
|
||||
{
|
||||
pragma_parameter_directives[name] = argregs;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
error ("malformed #pragma parameter ");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
m68k_register_pragmas()
|
||||
{
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
std::string n(1, '0' + i);
|
||||
pragma_parameter_register_names["__D" + n] = i;
|
||||
pragma_parameter_register_names["__A" + n] = i + 8;
|
||||
}
|
||||
c_register_pragma (NULL, "parameter", m68k_pragma_parameter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "gt-m68k.h"
|
||||
|
@ -198,7 +198,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
while (0)
|
||||
|
||||
|
||||
extern void m68k_register_pragmas();
|
||||
extern void m68k_register_pragmas(void);
|
||||
/* Target Pragmas. */
|
||||
#define REGISTER_TARGET_PRAGMAS() m68k_register_pragmas ()
|
||||
|
||||
@ -536,7 +536,7 @@ typedef struct {
|
||||
int bytes; /* number of bytes of arguments scanned so far. */
|
||||
int total_count;
|
||||
int index;
|
||||
bool regparam;
|
||||
int regparam;
|
||||
int arg_regs[32];
|
||||
|
||||
} CUMULATIVE_ARGS;
|
||||
@ -1005,5 +1005,5 @@ extern int m68k_sched_indexed_address_bypass_p (rtx, rtx);
|
||||
} \
|
||||
while (0)
|
||||
|
||||
extern bool m68k_is_pascal_func(tree, tree);
|
||||
extern int m68k_is_pascal_func(tree, tree);
|
||||
#define IS_PASCAL_FUNC(fntype, fndecl) m68k_is_pascal_func(fntype, fndecl)
|
@ -2,3 +2,7 @@
|
||||
|
||||
M68K_MLIB_CPU += && (CPU !~ "^mcf")
|
||||
M68K_ARCH := m68k
|
||||
|
||||
m68k-mac-pragmas.o: $(srcdir)/config/m68k/m68k-mac-pragmas.c
|
||||
$(COMPILE) $<
|
||||
$(POSTCOMPILE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user