aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc/eabi/CPragmas.ml
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-10 12:15:43 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-10 12:15:43 +0000
commita32ed5df6aa31aa5a38a55af9d75880e906721f2 (patch)
tree737bf6863dde159547d11941fde0af70ffad3278 /powerpc/eabi/CPragmas.ml
parentbae0ed25d01388093ebcb4b32db0b6d1169f17db (diff)
downloadcompcert-a32ed5df6aa31aa5a38a55af9d75880e906721f2.tar.gz
compcert-a32ed5df6aa31aa5a38a55af9d75880e906721f2.zip
Coloring: allow to exclude user-specified registers from allocation.
CPragmas (PPC/EABI only): add #pragma reserve_register git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1314 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'powerpc/eabi/CPragmas.ml')
-rw-r--r--powerpc/eabi/CPragmas.ml31
1 files changed, 28 insertions, 3 deletions
diff --git a/powerpc/eabi/CPragmas.ml b/powerpc/eabi/CPragmas.ml
index 4bb7786e..3104cc88 100644
--- a/powerpc/eabi/CPragmas.ml
+++ b/powerpc/eabi/CPragmas.ml
@@ -68,6 +68,8 @@ let _ =
sec_near_access = false}
]
+(* #pragma section *)
+
let process_section_pragma classname istring ustring addrmode accmode =
let old_si =
try Hashtbl.find section_table classname
@@ -85,6 +87,7 @@ let process_section_pragma classname istring ustring addrmode accmode =
else (addrmode = "near-code") || (addrmode = "near-data") } in
Hashtbl.add section_table classname si
+(* #pragma use_section *)
let use_section_table : (AST.ident, section_info) Hashtbl.t =
Hashtbl.create 51
@@ -122,6 +125,19 @@ let define_variable id d =
if is_small !Clflags.option_small_data then "SDATA" else "DATA" in
default_use_section id sect
+(* #pragma reserve_register *)
+
+let process_reserve_register_pragma name =
+ match Machregsaux.register_by_name name with
+ | None ->
+ C2Clight.error "unknown register in `reserve_register' pragma"
+ | Some r ->
+ if Machregsaux.can_reserve_register r then
+ Coloringaux.reserved_registers :=
+ r :: !Coloringaux.reserved_registers
+ else
+ C2Clight.error "cannot reserve this register (not a callee-save)"
+
(* Parsing of pragmas using regexps *)
let re_start_pragma_section = Str.regexp "section\\b"
@@ -144,6 +160,11 @@ let re_pragma_use_section = Str.regexp
let re_split_idents = Str.regexp "[ \t,]+"
+let re_start_pragma_reserve_register = Str.regexp "reserve_register\\b"
+
+let re_pragma_reserve_register = Str.regexp
+ "reserve_register[ \t]+\\([A-Za-z0-9]+\\)"
+
let process_pragma name =
if Str.string_match re_pragma_section name 0 then begin
process_section_pragma
@@ -162,9 +183,13 @@ let process_pragma name =
if identlist = [] then C2Clight.warning "vacuous `use_section' pragma";
List.iter (process_use_section_pragma classname) identlist;
true
- end else if Str.string_match re_start_pragma_use_section name 0 then
- (C2Clight.error "ill-formed `use_section' pragma"; true)
- else
+ end else if Str.string_match re_start_pragma_use_section name 0 then begin
+ C2Clight.error "ill-formed `use_section' pragma"; true
+ end else if Str.string_match re_pragma_reserve_register name 0 then begin
+ process_reserve_register_pragma (Str.matched_group 1 name); true
+ end else if Str.string_match re_start_pragma_reserve_register name 0 then begin
+ C2Clight.error "ill-formed `reserve_register' pragma"; true
+ end else
false
let initialize () =