2018-07-22 12:24:36 +00:00
|
|
|
;;; GNU Mes --- Maxwell Equations of Software
|
2017-11-21 18:22:26 +00:00
|
|
|
;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
;;;
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; This file is part of GNU Mes.
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
;;;
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; GNU Mes is free software; you can redistribute it and/or modify it
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; GNU Mes is distributed in the hope that it will be useful, but
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
|
2018-05-25 06:05:02 +00:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; info.scm defines [Guile] record data types for MesCC
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2018-05-25 06:05:02 +00:00
|
|
|
(define-module (mescc info)
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
#:use-module (ice-9 optargs)
|
2017-07-14 19:26:35 +00:00
|
|
|
#:use-module (srfi srfi-9)
|
|
|
|
#:use-module (srfi srfi-9 gnu)
|
2018-05-04 18:45:27 +00:00
|
|
|
#:use-module (srfi srfi-26)
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
#:export (<info>
|
|
|
|
make
|
2018-05-25 06:05:02 +00:00
|
|
|
clone
|
2017-07-14 19:26:35 +00:00
|
|
|
make-<info>
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
info?
|
|
|
|
|
|
|
|
.types
|
|
|
|
.constants
|
|
|
|
.functions
|
|
|
|
.globals
|
|
|
|
.locals
|
|
|
|
.function
|
2018-05-04 18:45:27 +00:00
|
|
|
.statics
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
.text
|
2018-05-13 11:50:32 +00:00
|
|
|
.post
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
.break
|
2017-07-15 08:40:31 +00:00
|
|
|
.continue
|
2018-08-14 10:35:24 +00:00
|
|
|
.allocated
|
2018-08-15 16:26:55 +00:00
|
|
|
.pushed
|
2018-08-14 10:35:24 +00:00
|
|
|
.registers
|
2018-08-14 18:32:56 +00:00
|
|
|
.instructions
|
2017-07-15 08:40:31 +00:00
|
|
|
|
2018-05-04 11:58:27 +00:00
|
|
|
<type>
|
2017-07-15 09:24:14 +00:00
|
|
|
make-type
|
|
|
|
type?
|
2017-07-15 08:40:31 +00:00
|
|
|
type:type
|
|
|
|
type:size
|
|
|
|
type:pointer
|
2017-07-15 09:24:14 +00:00
|
|
|
type:description
|
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
<c-array>
|
|
|
|
make-c-array
|
|
|
|
c-array?
|
|
|
|
c-array:type
|
|
|
|
c-array:count
|
|
|
|
|
|
|
|
<pointer>
|
|
|
|
make-pointer
|
|
|
|
pointer?
|
|
|
|
pointer:type
|
|
|
|
pointer:rank
|
|
|
|
|
2018-05-13 15:05:28 +00:00
|
|
|
<bit-field>
|
|
|
|
make-bit-field
|
|
|
|
bit-field?
|
|
|
|
bit-field:type
|
|
|
|
bit-field:bit
|
|
|
|
bit-field:bits
|
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
<var>
|
|
|
|
var:name
|
|
|
|
var:type
|
|
|
|
var:pointer
|
|
|
|
var:c-array
|
|
|
|
|
2018-05-04 11:58:27 +00:00
|
|
|
<global>
|
2017-07-15 09:24:14 +00:00
|
|
|
make-global
|
|
|
|
global?
|
2018-05-04 18:45:27 +00:00
|
|
|
global:name
|
2017-07-15 09:24:14 +00:00
|
|
|
global:type
|
|
|
|
global:pointer
|
2018-05-09 19:31:23 +00:00
|
|
|
global:c-array
|
|
|
|
global:var
|
2017-07-15 09:46:13 +00:00
|
|
|
global:value
|
2019-07-27 15:22:00 +00:00
|
|
|
global:storage
|
2018-05-04 18:45:27 +00:00
|
|
|
global:function
|
|
|
|
global->string
|
2017-07-15 09:46:13 +00:00
|
|
|
|
2018-05-04 11:58:27 +00:00
|
|
|
<local>
|
2017-07-15 09:46:13 +00:00
|
|
|
make-local
|
|
|
|
local?
|
|
|
|
local:type
|
|
|
|
local:pointer
|
2018-05-09 19:31:23 +00:00
|
|
|
local:c-array
|
|
|
|
local:var
|
2018-05-04 11:58:27 +00:00
|
|
|
local:id
|
|
|
|
|
|
|
|
<function>
|
|
|
|
make-function
|
|
|
|
function?
|
|
|
|
function:name
|
|
|
|
function:type
|
2018-05-09 19:31:23 +00:00
|
|
|
function:text
|
2018-05-11 17:46:26 +00:00
|
|
|
function->string
|
2018-05-09 19:31:23 +00:00
|
|
|
|
2018-05-10 10:40:07 +00:00
|
|
|
->type
|
2018-05-09 19:31:23 +00:00
|
|
|
->rank
|
|
|
|
rank--
|
|
|
|
rank++
|
2018-05-10 15:11:21 +00:00
|
|
|
rank+=
|
2018-05-09 19:31:23 +00:00
|
|
|
structured-type?))
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
|
2017-07-14 19:26:35 +00:00
|
|
|
(define-immutable-record-type <info>
|
2018-08-15 16:26:55 +00:00
|
|
|
(make-<info> types constants functions globals locals statics function text post break continue allocated pushed registers instructions)
|
2017-07-14 19:26:35 +00:00
|
|
|
info?
|
|
|
|
(types .types)
|
|
|
|
(constants .constants)
|
|
|
|
(functions .functions)
|
|
|
|
(globals .globals)
|
|
|
|
(locals .locals)
|
2018-05-04 18:45:27 +00:00
|
|
|
(statics .statics)
|
2017-07-14 19:26:35 +00:00
|
|
|
(function .function)
|
|
|
|
(text .text)
|
2018-05-13 11:50:32 +00:00
|
|
|
(post .post)
|
2017-07-14 19:26:35 +00:00
|
|
|
(break .break)
|
2018-08-14 10:35:24 +00:00
|
|
|
(continue .continue)
|
2018-08-14 18:32:56 +00:00
|
|
|
(allocated .allocated)
|
2018-08-15 16:26:55 +00:00
|
|
|
(pushed .pushed)
|
2018-08-14 10:35:24 +00:00
|
|
|
(registers .registers)
|
2018-08-14 18:32:56 +00:00
|
|
|
(instructions .instructions))
|
mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
|
2018-08-15 16:26:55 +00:00
|
|
|
(define* (make o #:key (types '()) (constants '()) (functions '()) (globals '()) (locals '()) (statics '()) (function #f) (text '()) (post '()) (break '()) (continue '()) (allocated '()) (pushed 0) (registers '()) (instructions '()))
|
2018-05-25 06:05:02 +00:00
|
|
|
(cond ((eq? o <info>)
|
2018-08-15 16:26:55 +00:00
|
|
|
(make-<info> types constants functions globals locals statics function text post break continue allocated pushed registers instructions))))
|
2018-05-25 06:05:02 +00:00
|
|
|
|
|
|
|
(define (clone o . rest)
|
|
|
|
(cond ((info? o)
|
|
|
|
(let ((types (.types o))
|
|
|
|
(constants (.constants o))
|
|
|
|
(functions (.functions o))
|
|
|
|
(globals (.globals o))
|
|
|
|
(locals (.locals o))
|
|
|
|
(statics (.statics o))
|
|
|
|
(function (.function o))
|
|
|
|
(text (.text o))
|
|
|
|
(post (.post o))
|
|
|
|
(break (.break o))
|
2018-08-14 10:35:24 +00:00
|
|
|
(continue (.continue o))
|
|
|
|
(allocated (.allocated o))
|
2018-08-15 16:26:55 +00:00
|
|
|
(pushed (.pushed o))
|
2018-08-14 18:32:56 +00:00
|
|
|
(registers (.registers o))
|
|
|
|
(instructions (.instructions o)))
|
2018-05-25 06:05:02 +00:00
|
|
|
(let-keywords rest
|
|
|
|
#f
|
|
|
|
((types types)
|
|
|
|
(constants constants)
|
|
|
|
(functions functions)
|
|
|
|
(globals globals)
|
|
|
|
(locals locals)
|
|
|
|
(statics statics)
|
|
|
|
(function function)
|
|
|
|
(text text)
|
|
|
|
(post post)
|
|
|
|
(break break)
|
2018-08-14 10:35:24 +00:00
|
|
|
(continue continue)
|
|
|
|
(allocated allocated)
|
2018-08-15 16:26:55 +00:00
|
|
|
(pushed pushed)
|
2018-08-14 18:32:56 +00:00
|
|
|
(registers registers)
|
|
|
|
(instructions instructions))
|
2018-08-15 16:26:55 +00:00
|
|
|
(make <info> #:types types #:constants constants #:functions functions #:globals globals #:locals locals #:statics statics #:function function #:text text #:post post #:break break #:continue continue #:allocated allocated #:pushed pushed #:registers registers #:instructions instructions))))))
|
2017-07-15 08:40:31 +00:00
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
;; ("int" . ,(make-type 'builtin 4 #f 0 #f))
|
|
|
|
;; (make-type 'enum 4 0 fields)
|
|
|
|
;; (make-type 'struct (apply + (map field:size fields)) 0 fields)
|
|
|
|
|
2017-07-15 08:40:31 +00:00
|
|
|
(define-immutable-record-type <type>
|
2018-05-09 19:31:23 +00:00
|
|
|
(make-type type size description)
|
2017-07-15 08:40:31 +00:00
|
|
|
type?
|
|
|
|
(type type:type)
|
|
|
|
(size type:size)
|
|
|
|
(description type:description))
|
2017-07-15 09:24:14 +00:00
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
(define-immutable-record-type <c-array>
|
|
|
|
(make-c-array type count)
|
|
|
|
c-array?
|
|
|
|
(type c-array:type)
|
|
|
|
(count c-array:count))
|
|
|
|
|
|
|
|
(define-immutable-record-type <pointer>
|
|
|
|
(make-pointer type rank)
|
|
|
|
pointer?
|
|
|
|
(type pointer:type)
|
|
|
|
(rank pointer:rank))
|
|
|
|
|
2018-05-13 15:05:28 +00:00
|
|
|
(define-immutable-record-type <bit-field>
|
|
|
|
(make-bit-field type bit bits)
|
|
|
|
bit-field?
|
|
|
|
(type bit-field:type)
|
|
|
|
(bit bit-field:bit)
|
|
|
|
(bits bit-field:bits))
|
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
(define-immutable-record-type <var>
|
|
|
|
(make-var name type function id value)
|
|
|
|
var?
|
|
|
|
(name var:name)
|
|
|
|
(type var:type) ; <type>
|
|
|
|
(function var:function)
|
|
|
|
(id var:id)
|
|
|
|
(value var:value))
|
|
|
|
|
2017-07-15 09:24:14 +00:00
|
|
|
(define-immutable-record-type <global>
|
2019-07-27 15:22:00 +00:00
|
|
|
(make-global- name type var value storage function)
|
2017-07-15 09:24:14 +00:00
|
|
|
global?
|
2018-05-04 18:45:27 +00:00
|
|
|
(name global:name)
|
2017-07-15 09:24:14 +00:00
|
|
|
(type global:type)
|
2018-05-09 19:31:23 +00:00
|
|
|
(var global:var) ; <var>
|
|
|
|
|
2018-05-04 18:45:27 +00:00
|
|
|
(value global:value)
|
2019-07-27 15:22:00 +00:00
|
|
|
(storage global:storage)
|
2018-05-04 18:45:27 +00:00
|
|
|
(function global:function))
|
|
|
|
|
2019-07-27 15:22:00 +00:00
|
|
|
(define (make-global name type value storage function)
|
|
|
|
(make-global- name type (make-var name type function #f value) value storage function))
|
2018-05-09 19:31:23 +00:00
|
|
|
|
2018-05-04 18:45:27 +00:00
|
|
|
(define (global->string o)
|
|
|
|
(or (and=> (global:function o) (cut string-append <> "-" (global:name o)))
|
|
|
|
(global:name o)))
|
2017-07-15 09:46:13 +00:00
|
|
|
|
|
|
|
(define-immutable-record-type <local>
|
2018-05-10 10:40:07 +00:00
|
|
|
(make-local- type var id)
|
2017-07-15 09:46:13 +00:00
|
|
|
local?
|
|
|
|
(type local:type)
|
2018-05-09 19:31:23 +00:00
|
|
|
(var local:var) ; <var>
|
|
|
|
|
2018-05-10 10:40:07 +00:00
|
|
|
(id local:id))
|
2018-05-09 19:31:23 +00:00
|
|
|
|
2018-05-10 10:40:07 +00:00
|
|
|
(define (make-local name type id)
|
|
|
|
(make-local- type (make-var name type #f id #f) id))
|
2018-05-04 11:58:27 +00:00
|
|
|
|
|
|
|
(define-immutable-record-type <function>
|
|
|
|
(make-function name type text)
|
|
|
|
function?
|
|
|
|
(name function:name)
|
|
|
|
(type function:type)
|
|
|
|
(text function:text))
|
2018-05-09 19:31:23 +00:00
|
|
|
|
2018-05-11 17:46:26 +00:00
|
|
|
(define (function->string o)
|
|
|
|
(function:name o))
|
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
(define (structured-type? o)
|
|
|
|
(cond ((type? o) (memq (type:type o) '(struct union)))
|
|
|
|
((global? o) ((compose structured-type? global:type) o))
|
|
|
|
((local? o) ((compose structured-type? local:type) o))
|
|
|
|
((and (pair? o) (eq? (car o) 'tag))) ;; FIXME: enum?
|
|
|
|
(else #f)))
|
|
|
|
|
2018-05-10 10:40:07 +00:00
|
|
|
(define (->type o)
|
2018-05-09 19:31:23 +00:00
|
|
|
(cond ((type? o) o)
|
2018-05-13 15:05:28 +00:00
|
|
|
((bit-field? o) o)
|
mescc: Tinycc support: Char and short sign extend.
* module/mes/as-i386.mes (i386:accu*n->local, i386:byte-accu->local+n,
i386:word-accu->local+n): Remove.
(i386:byte-accu, i386:signed-byte-accu, i386:word-accu,
i386:signed-word-accu): New function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (accu->local+n-text): Simplify.
(mem->accu, convert-accu): New function.
(expr->accu): Use them.
* stage0/x86.M1 (mov____%al,0x32(%ebp), mov____%al,0x8(%ebp),
mov____%ax,0x32(%ebp), mov____%ax,0x8(%ebp), movzbl_0x32(%ebp),%eax,
movzbl_0x8(%ebp),%eax, movzwl_0x32(%ebp),%eax,
movzwl_0x8(%ebp),%eax): Deprecate.
* scaffold/tests/7r-sign-extend.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-05-18 21:58:10 +00:00
|
|
|
((pointer? o) ((compose ->type pointer:type) o))
|
|
|
|
((c-array? o) ((compose ->type c-array:type) o))
|
2018-05-09 19:31:23 +00:00
|
|
|
((and (pair? o) (eq? (car o) 'tag)) o)
|
|
|
|
;; FIXME
|
|
|
|
(#t
|
|
|
|
(format (current-error-port) "->type--: not a <type>: ~s\n" o)
|
|
|
|
(make-type 'builtin 4 #f))
|
2018-05-10 10:40:07 +00:00
|
|
|
(else (error "->type: not a <type>:" o))))
|
2018-05-09 19:31:23 +00:00
|
|
|
|
|
|
|
(define (->rank o)
|
|
|
|
(cond ((type? o) 0)
|
|
|
|
((pointer? o) (pointer:rank o))
|
2018-05-10 15:11:21 +00:00
|
|
|
((c-array? o) (1+ ((compose ->rank c-array:type) o)))
|
|
|
|
((local? o) ((compose ->rank local:type) o))
|
|
|
|
((global? o) ((compose ->rank global:type) o))
|
2018-05-13 15:05:28 +00:00
|
|
|
((bit-field? o) 0)
|
2018-05-09 19:31:23 +00:00
|
|
|
;; FIXME
|
|
|
|
(#t
|
2018-05-10 15:11:21 +00:00
|
|
|
(format (current-error-port) "->rank: not a type: ~s\n" o)
|
2018-05-09 19:31:23 +00:00
|
|
|
0)
|
|
|
|
(else (error "->rank: not a <type>:" o))))
|
|
|
|
|
|
|
|
(define (rank-- o)
|
2018-05-10 15:11:21 +00:00
|
|
|
(cond ((and (pointer? o) (= (pointer:rank o) 1)) (pointer:type o))
|
2018-05-09 19:31:23 +00:00
|
|
|
((pointer? o) (set-field o (pointer:rank) (1- (pointer:rank o))))
|
2018-05-10 15:11:21 +00:00
|
|
|
((c-array? o) (c-array:type o))
|
2018-05-09 19:31:23 +00:00
|
|
|
;; FIXME
|
|
|
|
(#t (format (current-error-port) "rank--: not a pointer: ~s\n" o)
|
|
|
|
o)
|
|
|
|
(else (error "rank--: not a pointer" o))))
|
|
|
|
|
2018-05-10 15:11:21 +00:00
|
|
|
(define (rank+= o i)
|
|
|
|
(cond ((pointer? o) (set-field o (pointer:rank) (+ i (pointer:rank o))))
|
|
|
|
(else (make-pointer o i))))
|
|
|
|
|
2018-05-09 19:31:23 +00:00
|
|
|
(define (rank++ o)
|
2018-05-10 15:11:21 +00:00
|
|
|
(rank+= o 1))
|