Code Search for Developers
 
 
  

sim-arch.scm from Gdb at Krugle


Show sim-arch.scm syntax highlighted

; Simulator generator support routines.
; Copyright (C) 2000 Red Hat, Inc.
; This file is part of CGEN.

; Utilities of cgen-arch.h.

; Return C macro definitions of the various supported cpus.

(define (-gen-cpuall-defines)
  "" ; nothing yet
)

; Return C declarations of misc. support stuff.
; ??? Modes are now defined in sim/common/cgen-types.h but we will need
; target specific modes.

(define (-gen-support-decls)
  (string-append
;   (gen-enum-decl 'mode_type "mode types"
;		  "MODE_"
;		  ; Aliases are not distinct from their real mode so ignore
;		  ; them here.
;		  (append (map list (map obj:name
;					 (mode-list-non-alias-values)))
;			  '((max))))
;   "#define MAX_MODES ((int) MODE_MAX)\n\n"
   )
)

; Utilities of cgen-cpuall.h.

; Subroutine of -gen-cpuall-includes.

(define (-gen-cpu-header cpu prefix)
  (string-append "#include \"" prefix (cpu-file-transform cpu) ".h\"\n")
)

; Return C code to include all the relevant headers for each cpu family,
; conditioned on ifdef WANT_CPU_@CPU@.

(define (-gen-cpuall-includes)
  (string-list
   "/* Include files for each cpu family.  */\n\n"
   (string-list-map (lambda (cpu)
		      (let* ((cpu-name (gen-sym cpu))
			     (CPU-NAME (string-upcase cpu-name)))
			(string-list "#ifdef WANT_CPU_" CPU-NAME "\n"
				     (-gen-cpu-header cpu "eng")
				     "#include \"cgen-engine.h\"\n"
				     (-gen-cpu-header cpu "cpu")
				     ; FIXME: Shorten "decode" to "dec".
				     (-gen-cpu-header cpu "decode")
				     "#endif\n\n")))
		    (current-cpu-list))
   )
)

; Subroutine of -gen-cpuall-decls to generate cpu-specific structure entries.
; The result is "struct <cpu>_<type-name> <member-name>;".
; INDENT is the amount to indent by.
; CPU is the cpu object.

(define (-gen-cpu-specific-decl indent cpu type-name member-name)
  (let* ((cpu-name (gen-sym cpu))
	 (CPU-NAME (string-upcase cpu-name)))
    (string-append
     "#ifdef WANT_CPU_" CPU-NAME "\n"
     (spaces indent)
     "struct " cpu-name "_" type-name " " member-name ";\n"
     "#endif\n"))
)

; Return C declarations of cpu-specific structs.
; These are defined here to achieve a simple and moderately type-safe
; inheritance.  In the non-cpu-specific files, these structs consist of
; just the baseclass.  In cpu-specific files, the baseclass is augmented
; with the cpu-specific data.

(define (-gen-cpuall-decls)
  (string-list
   (gen-argbuf-type #f)
   (gen-scache-type #f)
   )
)

; Top level generators for non-cpu-specific files.

; Generate arch.h
; This file defines non cpu family specific data about the architecture
; and also data structures that combine all variants (e.g. cpu struct).
; It is intended to be included before sim-basics.h and sim-base.h.

(define (cgen-arch.h)
  (logit 1 "Generating arch.h ...\n")

  (string-write
   (gen-c-copyright "Simulator header for @arch@."
		  CURRENT-COPYRIGHT CURRENT-PACKAGE)
   "#ifndef @ARCH@_ARCH_H\n"
   "#define @ARCH@_ARCH_H\n"
   "\n"
   "#define TARGET_BIG_ENDIAN 1\n\n" ; FIXME
   ;(gen-mem-macros)
   ;"/* FIXME: split into 32/64 parts */\n"
   ;"#define WI SI\n"
   ;"#define UWI USI\n"
   ;"#define AI USI\n\n"
   -gen-cpuall-defines
   -gen-support-decls
   -gen-arch-model-decls
   "#endif /* @ARCH@_ARCH_H */\n"
   )
)

; Generate arch.c
; This file defines non cpu family specific data about the architecture.

(define (cgen-arch.c)
  (logit 1 "Generating arch.c ...\n")

  (string-write
   (gen-c-copyright "Simulator support for @arch@."
		  CURRENT-COPYRIGHT CURRENT-PACKAGE)
   "\
#include \"sim-main.h\"
#include \"bfd.h\"

"
   -gen-mach-data
   )
)

; Generate cpuall.h
; This file pulls together all of the cpu variants .h's.
; It is intended to be included after sim-base.h/cgen-sim.h.

(define (cgen-cpuall.h)
  (logit 1 "Generating cpuall.h ...\n")

  (string-write
   (gen-c-copyright "Simulator CPU header for @arch@."
		  CURRENT-COPYRIGHT CURRENT-PACKAGE)
   "#ifndef @ARCH@_CPUALL_H\n"
   "#define @ARCH@_CPUALL_H\n"
   "\n"
   -gen-cpuall-includes
   -gen-mach-decls
   -gen-cpuall-decls
   "#endif /* @ARCH@_CPUALL_H */\n"
   )
)

; Generate ops.c
; No longer used.

(define (cgen-ops.c)
  (logit 1 "Generating ops.c ...\n")

  (string-write
   (gen-c-copyright "Simulator operational support for @arch@."
		  CURRENT-COPYRIGHT CURRENT-PACKAGE)
   "\
#define MEMOPS_DEFINE_INLINE

#include \"config.h\"
#include <signal.h>
#include \"ansidecl.h\"
#include \"bfd.h\"
#include \"tconfig.h\"
#include \"cgen-sim.h\"
#include \"memops.h\"

/* FIXME: wip */
int pow2masks[] = {
  0, 0, 1, -1, 3, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, 15
};

"
   gen-mode-defs
   )
)




See more files for this project here

Gdb

GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.

Project homepage: http://sources.redhat.com/gdb/
Programming language(s): Assembly,C,C++,Expect
License: other

  cpu/
    arm.cpu
    arm.sim
    arm7.cpu
    fr30.cpu
    fr30.opc
    i960.cpu
    i960.opc
    ia32.cpu
    ia64.cpu
    ip2k.cpu
    ip2k.opc
    iq10.cpu
    iq2000.cpu
    iq2000.opc
    iq2000m.cpu
    m32r.cpu
    m32r.opc
    m68k.cpu
    openrisc.cpu
    openrisc.opc
    play.cpu
    powerpc.cpu
    sh-sid.cpu
    sh-sim.cpu
    sh.cpu
    sh.opc
    sh64-compact.cpu
    sh64-media.cpu
    simplify.inc
    sparc.cpu
    sparc.opc
    sparc32.cpu
    sparc64.cpu
    sparccom.cpu
    sparcfpu.cpu
    thumb.cpu
    xc16x.cpu
    xc16x.opc
    xstormy16.cpu
    xstormy16.opc
  doc/
    Makefile.am
    Makefile.in
    app.texi
    cgen.texi
    credits.texi
    glossary.texi
    internals.texi
    intro.texi
    notes.texi
    opcodes.texi
    pmacros.texi
    porting.texi
    rtl.texi
    running.texi
    sim.texi
    stamp-vti
    version.texi
  slib/
    genwrite.scm
    logical.scm
    pp.scm
    random.scm
    sort.scm
  AUTHORS
  COPYING.CGEN
  ChangeLog
  INSTALL
  Makefile.am
  Makefile.in
  NEWS
  README
  aclocal.m4
  attr.scm
  cgen-doc.scm
  cgen-gas.scm
  cgen-opc.scm
  cgen-sid.scm
  cgen-sim.scm
  cgen-stest.scm
  configure
  configure.in
  cos-pprint.scm
  cos.scm
  decode.scm
  desc-cpu.scm
  desc.scm
  dev.scm
  enum.scm
  gas-test.scm
  gen-all-doc
  gen-all-opcodes
  gen-all-sid
  gen-all-sim
  guile.scm
  hardware.scm
  html.scm
  ifield.scm
  iformat.scm
  insn.scm
  mach.scm
  minsn.scm
  mode.scm
  model.scm
  opc-asmdis.scm
  opc-ibld.scm
  opc-itab.scm
  opc-opinst.scm
  opcodes.scm
  operand.scm
  pgmr-tools.scm
  pmacros.scm
  pprint.scm
  profile.scm
  read.scm
  rtl-c.scm
  rtl-traverse.scm
  rtl.scm
  rtx-funcs.scm
  sem-frags.scm
  semantics.scm
  sid-cpu.scm
  sid-decode.scm
  sid-model.scm
  sid.scm
  sim-arch.scm
  sim-cpu.scm
  sim-decode.scm
  sim-model.scm
  sim-test.scm
  sim.scm
  stamp-h.in
  types.scm
  utils-cgen.scm
  utils-gen.scm
  utils-sim.scm
  utils.scm