| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- E X P _ C O D E -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1996-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
| 17 |
-- for more details. You should have received a copy of the GNU General -- |
| 18 |
-- Public License distributed with GNAT; see file COPYING3. If not, go to -- |
| 19 |
-- http://www.gnu.org/licenses for a complete copy of the license. -- |
| 20 |
-- -- |
| 21 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 22 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 23 |
-- -- |
| 24 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
-- Processing for handling code statements |
| 27 |
|
| 28 |
with Types; use Types; |
| 29 |
|
| 30 |
with System; use System; |
| 31 |
package Exp_Code is |
| 32 |
|
| 33 |
procedure Expand_Asm_Call (N : Node_Id); |
| 34 |
-- Expands a call to Asm into an equivalent N_Code_Statement node |
| 35 |
|
| 36 |
-- The following routines provide an abstract interface to analyze |
| 37 |
-- code statements, for use by Gigi processing for code statements. |
| 38 |
-- Note that the implementations of these routines must not attempt |
| 39 |
-- to expand tables that are frozen on entry to Gigi. |
| 40 |
|
| 41 |
-- WARNING: There is a matching C declaration of these subprograms in fe.h |
| 42 |
|
| 43 |
function Is_Asm_Volatile (N : Node_Id) return Boolean; |
| 44 |
-- Given an N_Code_Statement node N, return True if Volatile=True is |
| 45 |
-- specified, and False if Volatile=False is specified (or set by default). |
| 46 |
|
| 47 |
function Asm_Template (N : Node_Id) return Node_Id; |
| 48 |
-- Given an N_Code_Statement node N, returns string literal node for |
| 49 |
-- template in call |
| 50 |
|
| 51 |
procedure Clobber_Setup (N : Node_Id); |
| 52 |
-- Given an N_Code_Statement node N, setup to process the clobber list |
| 53 |
-- with subsequent calls to Clobber_Get_Next. |
| 54 |
|
| 55 |
function Clobber_Get_Next return System.Address; |
| 56 |
pragma Convention (C, Clobber_Get_Next); |
| 57 |
-- Can only be called after a previous call to Clobber_Setup. The |
| 58 |
-- returned value is a pointer to a null terminated (C format) string |
| 59 |
-- for the next register argument. Null_Address is returned when there |
| 60 |
-- are no more arguments. |
| 61 |
|
| 62 |
procedure Setup_Asm_Inputs (N : Node_Id); |
| 63 |
-- Given an N_Code_Statement node N, setup to read list of Asm_Input |
| 64 |
-- arguments. The protocol is to construct a loop as follows: |
| 65 |
-- |
| 66 |
-- Setup_Asm_Inputs (N); |
| 67 |
-- while Present (Asm_Input_Value) |
| 68 |
-- body |
| 69 |
-- Next_Asm_Input; |
| 70 |
-- end loop; |
| 71 |
-- |
| 72 |
-- where the loop body calls Asm_Input_Constraint or Asm_Input_Value to |
| 73 |
-- obtain the constraint string or input value expression from the current |
| 74 |
-- Asm_Input argument. |
| 75 |
|
| 76 |
function Asm_Input_Constraint return Node_Id; |
| 77 |
-- Called within a loop initialized by Setup_Asm_Inputs and controlled |
| 78 |
-- by Next_Asm_Input as described above. Returns a string literal node |
| 79 |
-- for the constraint component of the current Asm_Input_Parameter, or |
| 80 |
-- Empty if there are no more Asm_Input parameters. |
| 81 |
|
| 82 |
function Asm_Input_Value return Node_Id; |
| 83 |
-- Called within a loop initialized by Setup_Asm_Inputs and controlled |
| 84 |
-- by Next_Asm_Input as described above. Returns the expression node for |
| 85 |
-- the value component of the current Asm_Input parameter, or Empty if |
| 86 |
-- there are no more Asm_Input parameters, or Error if an error was |
| 87 |
-- previously detected in the input parameters (note that the backend |
| 88 |
-- need not worry about this case, since it won't be called if there |
| 89 |
-- were any such serious errors detected). |
| 90 |
|
| 91 |
procedure Next_Asm_Input; |
| 92 |
-- Step to next Asm_Input parameter. It is an error to call this procedure |
| 93 |
-- if there are no more available parameters (which is impossible if the |
| 94 |
-- call appears in a loop as in the above example). |
| 95 |
|
| 96 |
procedure Setup_Asm_Outputs (N : Node_Id); |
| 97 |
-- Given an N_Code_Statement node N, setup to read list of Asm_Output |
| 98 |
-- arguments. The protocol is to construct a loop as follows: |
| 99 |
-- |
| 100 |
-- Setup_Asm_Outputs (N); |
| 101 |
-- while Present (Asm_Output_Variable) |
| 102 |
-- body |
| 103 |
-- Next_Asm_Output; |
| 104 |
-- end loop; |
| 105 |
-- |
| 106 |
-- where the loop body calls Asm_Output_Constraint or Asm_Output_Variable |
| 107 |
-- to obtain the constraint string or output variable name from the current |
| 108 |
-- Asm_Output argument. |
| 109 |
|
| 110 |
function Asm_Output_Constraint return Node_Id; |
| 111 |
-- Called within a loop initialized by Setup_Asm_Outputs and controlled |
| 112 |
-- by Next_Asm_Output as described above. Returns a string literal node |
| 113 |
-- for the constraint component of the current Asm_Output_Parameter, or |
| 114 |
-- Empty if there are no more Asm_Output parameters. |
| 115 |
|
| 116 |
function Asm_Output_Variable return Node_Id; |
| 117 |
-- Called within a loop initialized by Setup_Asm_Outputs and controlled by |
| 118 |
-- Next_Asm_Output as described above. Returns the expression node for the |
| 119 |
-- output variable component of the current Asm_Output parameter, or Empty |
| 120 |
-- if there are no more Asm_Output parameters, or Error if an error was |
| 121 |
-- previously detected in the input parameters (note that the backend need |
| 122 |
-- not worry about this case, since it won't be called if there were any |
| 123 |
-- such serious errors detected). |
| 124 |
|
| 125 |
procedure Next_Asm_Output; |
| 126 |
-- Step to next Asm_Output parameter. It is an error to call this procedure |
| 127 |
-- if there are no more available parameters (which is impossible if the |
| 128 |
-- call appears in a loop as in the above example). |
| 129 |
|
| 130 |
end Exp_Code; |