2 ### Class SASPragmas: Create a SAS/C pragmas file #############################
10 my $class = ref($proto) || $proto;
12 $self->{SFD
} = $params{'sfd'};
13 bless ($self, $class);
19 my $sfd = $self->{SFD
};
25 $v =~ s/^\$[I]d: .*? ([0-9.]+).*/$1/;
26 $d =~ s
,^\
$[I
]d
: .*?
[0-9.]+ (\d
{4})/(\d{2})/(\d
{2}).*,($3.$2.$1),;
28 print "/* Automatically generated header! Do not edit! */\n";
29 print "#ifndef PRAGMAS_$sfd->{BASENAME}_PRAGMAS_H\n";
30 print "#define PRAGMAS_$sfd->{BASENAME}_PRAGMAS_H\n";
33 print "** \$VER: $$sfd{'basename'}_pragmas.h $v $d\n";
35 print "** Direct ROM interface (pragma) definitions.\n";
37 print "** $$sfd{'copyright'}\n";
38 print "** All Rights Reserved\n";
42 print "#if defined(LATTICE) || defined(__SASC) || defined(_DCC)\n";
43 print "#ifndef __CLIB_PRAGMA_LIBCALL\n";
44 print "#define __CLIB_PRAGMA_LIBCALL\n";
45 print "#endif /* __CLIB_PRAGMA_LIBCALL */\n";
46 print "#else /* __MAXON__, __STORM__ or AZTEC_C */\n";
47 print "#ifndef __CLIB_PRAGMA_AMICALL\n";
48 print "#define __CLIB_PRAGMA_AMICALL\n";
49 print "#endif /* __CLIB_PRAGMA_AMICALL */\n";
50 print "#endif /* */\n";
52 print "#if defined(__SASC_60) || defined(__STORM__)\n";
53 print "#ifndef __CLIB_PRAGMA_TAGCALL\n";
54 print "#define __CLIB_PRAGMA_TAGCALL\n";
55 print "#endif /* __CLIB_PRAGMA_TAGCALL */\n";
56 print "#endif /* __MAXON__, __STORM__ or AZTEC_C */\n";
63 my $prototype = $params{'prototype'};
64 my $sfd = $self->{SFD
};
66 # Don't process private functions
67 if ($prototype->{private
}) {
73 foreach my $reg (@
{$prototype->{regs
}}) {
76 if ($reg =~ /^d[0-7]$/) {
77 ($num) = $reg =~ /^d(.)/;
79 elsif ($reg =~ /^a[0-9]$/) {
80 ($num) = $reg =~ /^a(.)/;
87 $regs = sprintf "%x$regs", $num;
90 $regs .= '0'; #Result in d0
91 $regs .= $prototype->{numregs
};
93 if ($prototype->{type
} eq 'function') {
94 # Always use libcall, since access to 4 is very expensive
96 print "#ifdef __CLIB_PRAGMA_LIBCALL\n";
97 print " #pragma libcall $sfd->{base} $prototype->{funcname} ";
98 printf "%x $regs\n", $prototype->{bias
};
99 print "#endif /* __CLIB_PRAGMA_LIBCALL */\n";
100 print "#ifdef __CLIB_PRAGMA_AMICALL\n";
101 printf " #pragma amicall($sfd->{base}, 0x%x, $prototype->{funcname}(",
103 print join (',', @
{$prototype->{regs
}}) . "))\n";
104 print "#endif /* __CLIB_PRAGMA_AMICALL */\n";
106 elsif ($prototype->{type
} eq 'varargs') {
107 print "#ifdef __CLIB_PRAGMA_TAGCALL\n";
108 print " #ifdef __CLIB_PRAGMA_LIBCALL\n";
109 print " #pragma tagcall $sfd->{base} $prototype->{funcname} ";
110 printf "%x $regs\n", $prototype->{bias
};
111 print " #endif /* __CLIB_PRAGMA_LIBCALL */\n";
112 print " #ifdef __CLIB_PRAGMA_AMICALL\n";
113 printf " #pragma tagcall($sfd->{base}, 0x%x, $prototype->{funcname}(",
115 print join (',', @
{$prototype->{regs
}}) . "))\n";
116 print " #endif /* __CLIB_PRAGMA_AMICALL */\n";
117 print "#endif /* __CLIB_PRAGMA_TAGCALL */\n";
119 elsif ($prototype->{type
} eq 'cfunction') {
123 print STDERR
"$prototype->{funcname}: Unsupported function " .
131 my $sfd = $self->{SFD
};
134 print "#endif /* PRAGMAS_$sfd->{BASENAME}_PRAGMAS_H */\n";