Alter(or mess with) sun4i target flags a bit
[AROS.git] / tools / sfdc / MacroLP.pl
blobae218b326d84d70dd068feafe2ae95b9729e0fe8
2 ### Class MacroLP: Create a LP-style macro file ###############################
4 BEGIN {
5 package MacroLP;
6 use vars qw(@ISA);
7 @ISA = qw( Macro );
9 sub new {
10 my $proto = shift;
11 my $class = ref($proto) || $proto;
12 my $self = $class->SUPER::new( @_ );
13 bless ($self, $class);
15 $self->{macros_h} = "inline/macros.h";
17 return $self;
20 sub header {
21 my $self = shift;
22 my $sfd = $self->{SFD};
24 $self->SUPER::header (@_);
26 print "#ifndef __INLINE_MACROS_H\n";
27 print "#include <$self->{macros_h}>\n";
28 print "#endif /* !__INLINE_MACROS_H */\n";
29 print "\n";
31 if ($$sfd{'base'} ne '') {
32 print "#ifndef $self->{BASE}\n";
33 print "#define $self->{BASE} $$sfd{'base'}\n";
34 print "#endif /* !$self->{BASE} */\n";
35 print "\n";
39 sub function_start {
40 my $self = shift;
41 my %params = @_;
42 my $prototype = $params{'prototype'};
43 my $sfd = $self->{SFD};
45 if ($$prototype{'type'} eq 'function') {
47 $self->{FUNCARGTYPE} = '';
48 for my $argtype (@{$$prototype{'argtypes'}}) {
49 if ($argtype =~ /\(\*\)/) {
50 $self->{FUNCARGTYPE} = $argtype;
51 last;
55 printf " LP%d%s%s%s(0x%x, ", $$prototype{'numargs'},
56 $prototype->{nr} ? "NR" : "",
57 $prototype->{nb} ? "NB" : "",
58 $self->{FUNCARGTYPE} ne '' ? "FP" : "",
59 $$prototype{'bias'};
61 if (!$prototype->{nr}) {
62 print "$$prototype{'return'}, ";
65 print "$$prototype{'funcname'}";
67 else {
68 $self->SUPER::function_start (@_);
72 sub function_arg {
73 my $self = shift;
74 my %params = @_;
75 my $prototype = $params{'prototype'};
76 my $argtype = $params{'argtype'};
77 my $argname = $params{'argname'};
78 my $argreg = $params{'argreg'};
79 my $argnum = $params{'argnum'};
80 my $sfd = $self->{SFD};
82 if ($$prototype{'type'} eq 'function') {
83 if ($argtype =~ /\(\*\)/) {
84 print ", __fpt, $argname, $argreg";
86 else {
87 print ", $argtype, $argname, $argreg";
90 else {
91 $self->SUPER::function_arg (@_);
95 sub function_end {
96 my $self = shift;
97 my %params = @_;
98 my $prototype = $params{'prototype'};
99 my $sfd = $self->{SFD};
101 if ($$prototype{'type'} eq 'function') {
102 if (!$prototype->{nb}) {
103 print ", ,(___base)\\\n";
106 if ($self->{FUNCARGTYPE} ne '') {
107 my $fa = $self->{FUNCARGTYPE};
109 $fa =~ s/\(\*\)/(*__fpt)/;
111 print ", $fa";
114 print ")\n";
116 else {
117 $self->SUPER::function_end (@_);