2 Utilities for optimizations
3 Copyright (C) 2001 Justin David Smith, Caltech
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 (*** Registers and Operands ***)
32 Identify registers _used_ in an operand. This for some reason
33 appears to not be consistent with src_regs; at any rate, we need
34 this computation for AGI. *)
35 let regs_in_operand = function
46 | MemRegRegOffMul
(r1
, r2
, _
, _
) ->
53 Returns true if the register named appears in the operand *)
54 let reg_in_operand op r
=
55 List.mem r
(regs_in_operand op
)
59 Returns true if the operand indicated is an FPStack register *)
60 let is_fpstack = function
68 (* make_comment_string
69 Builds a comment that is placed immediately (before, after) the
70 instruction given (this is to ensure live-out and depth are ok. *)
71 let make_comment_string inst s
=
74 live_out
= inst
.live_out
;
75 live_class
= CodeNormal
;
76 live_depth
= inst
.live_depth
;
77 live_inst
= CommentString s
;
82 Similar to above, but build a CommentInst instead. *)
83 let make_comment_inst inst s
=
86 live_out
= inst
.live_out
;
87 live_class
= CodeNormal
;
88 live_depth
= inst
.live_depth
;
89 live_inst
= CommentInst
(s
, inst
.live_inst
);
93 let () = std_flags_help_section_text
"opt.x86"
94 "Optimizations specific to the X86 backend."