Commit 87dcfbf5 authored by Julian Kranz's avatar Julian Kranz

Merge branch 'master' of bitbucket.org:simona/gdsl-toolkit into experimental

parents f2046283 ea29755a
......@@ -19,8 +19,6 @@ nodist_include_HEADERS =
#HAVE_X86 = 1
#endif
EXEEXT=
# we need to add a dependency to the actual backend to this variable
libjgdsl_la_LIBADD =
libgdsl_multiplex_la_LIBADD =
......@@ -130,15 +128,15 @@ GDSLC_SML_FILES = \
JAR=jgdsl.jar
GDSLC_DEP = detail/codegen/c1/runtime.c detail/codegen/c1/runtime.h
GDSLFLAGS = --runtime=$(srcdir)/detail/codegen
GDSLFLAGS = --runtime=$(srcdir)/detail/codegen @EXTRA_GDSL_FLAGS@
if HAVE_MLTON
$(builddir)/gdslc: $(srcdir)/gdslc.mlb $(GDSLC_SML_FILES)
$(MLTON) -output $(builddir)/gdslc $(srcdir)/gdslc.mlb
$(builddir)/gdslc$(EXEEXT): $(srcdir)/gdslc.mlb $(GDSLC_SML_FILES)
$(MLTON) -output $(builddir)/gdslc$(EXEEXT) $(srcdir)/gdslc.mlb
GDSLC_DEP += $(builddir)/gdslc
GDSLC = $(builddir)/gdslc
GDSLC_DEP += $(builddir)/gdslc$(EXEEXT)
GDSLC = $(builddir)/gdslc$(EXEEXT)
else
......@@ -617,4 +615,55 @@ endif
private_headers += $(srcdir)/tools/x86-test-stats-runner/src/hash_array.h
#endif
EXTRA_DIST = LICENSE $(GDSL_BASIS) $(GDSL_ASM) $(GDSL_X86) $(GDSL_RREIL) $(GDSL_X86SEM) $(GDSL_AVR) $(GDSL_AVRSEM) $(GDSL_MIPS) $(GDSL_MIPSSEM) $(private_headers) $(RUNTIME) $(srcdir)/gdsl.h $(srcdir)/gdslc.mlb $(srcdir)/gdsl.cm $(GDSLC_SML_FILES) $(srcdir)/detail/ml/smlnj/unsealed.cm
EXTRA_DIST = LICENSE $(GDSL_BASIS) $(GDSL_ASM) $(GDSL_X86) $(GDSL_RREIL) $(GDSL_X86SEM) $(GDSL_AVR) $(GDSL_AVRSEM) $(GDSL_MIPS) $(GDSL_MIPSSEM) $(private_headers) $(RUNTIME) $(srcdir)/gdsl.h $(srcdir)/gdslc.mlb $(srcdir)/gdsl.cm $(GDSLC_SML_FILES) $(srcdir)/detail/ml/smlnj/unsealed.cm build.bat
WINDOWS_DISTFILES = $(GDSLC) LICENSE $(GDSL_BASIS) $(GDSL_ASM) $(GDSL_X86) $(GDSL_RREIL) $(GDSL_X86SEM) $(GDSL_AVR) $(GDSL_AVRSEM) $(GDSL_MIPS) $(GDSL_MIPSSEM) $(RUNTIME) build.bat
# distribution .tgz file for Windows
.PHONY: windows-distdir windows-dist
# this ugly stuff is copied from what automake generates
windows-distdir: $(WINDOWS_DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(WINDOWS_DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
windows-dist : windows-distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >win-$(distdir).tar.gz
$(am__remove_distdir)
@ECHO OFF
setlocal ENABLEEXTENSIONS
rem This file is to be run on the Windows command line and generates the specified decoders.
rem
set ARGS=
rem remove bogus quotes from the PATH variable, that every path is in quotes
set LOCALPATH=%PATH:"=%
set LOCALPATH="%LOCALPATH:;=" "%"
rem let the user specify an output directory
set OUTDIR=
if NOT "%1"=="/odir" goto NoDir
set ARGS=%ARGS% %1
shift
set OUTDIR=%1
set ARGS=%ARGS% %1
shift
:NoDir
rem check if we find the Visual Studio compiler
set MSVC=
for %%p in (%LOCALPATH%) do if exist "%%~p\cl.exe" set MSVC="%%~p\cl.exe"
rem let the user specify the path to the C compiler
if NOT "%1"=="/cl" goto NoComp
set ARGS=%ARGS% %1
shift
set CL=%1
set ARGS=%ARGS% %1
shift
if exist %CL% goto NoComp
echo The compiler %CL% does not exist!
goto Error
:NoComp
rem let the user specify the Windows SDK lib directory
set SDKLIBPATH=
if NOT "%1"=="/sdklib" goto NoSDKLIB
set ARGS=%ARGS% %1
shift
set SDKLIBPATH=%1
set ARGS=%ARGS% %1
shift
:NoSDKLIB
SET DECODERS=x86 x86-rreil avr avr-rreil mips mips-rreil arm7
if "%1"=="" for %%d in (%DECODERS%) do build.bat %ARGS% %%d
for %%d IN (%DECODERS%) DO if "%1"=="%%d" set DECODER=%%d& goto Build
:Usage
echo Usage: build.bat [/odir "output-directory"] [/cl "cl-path"]
echo [/sdklib "sdklib-path"] ["decoder"]
echo where "cl-path" is the path to the Visual C compiler (ending in cl.exe)
echo and"sdklib-path" is the path to the \lib directory of the Windows SDK
echo and "decoder" may be omitted to build all or is one of the following:
for %%a in (%DECODERS%) do for /f "tokens=1,2 delims=-" %%d in ("%%a") do (
if "%%e"=="" (
echo %%d the %%d decoder and pretty printer
) ELSE (
echo %%d-%%e the %%d decoder, pretty printer and translation to %%e
)
)
goto End
:Build
echo off
rem keep these lists in sync with Makefile.am
set GDSL_BASIS=
set GDSL_BASIS=%GDSL_BASIS% specifications/basis/prelude.ml
set GDSL_BASIS=%GDSL_BASIS% specifications/basis/tree-set.ml
set GDSL_BASIS=%GDSL_BASIS% specifications/basis/bbtree.ml
set GDSL_ASM=
set GDSL_ASM=%GDSL_ASM% specifications/asm/asm-cif.ml
set GDSL_ASM=%GDSL_ASM% specifications/asm/asm.ml
set GDSL_ASM=%GDSL_ASM% specifications/asm/asm-pretty.ml
set GDSL_X86=
set GDSL_X86=%GDSL_X86% specifications/x86/x86.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-traverse.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-pretty.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-asm.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-semantics-mapping.ml
set GDSL_X86=%GDSL_X86% specifications/x86/x86-semantics-mapping-pretty.ml
set GDSL_X86SEM=
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-rreil-translator.ml
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-rreil-translator-a-l.ml
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-rreil-translator-m-z.ml
set GDSL_X86SEM=%GDSL_X86SEM% specifications/x86/x86-liveness.ml
set GDSL_AVR=
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr.ml
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr-asm.ml
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr-traverse.ml
set GDSL_AVR=%GDSL_AVR% specifications/avr/avr-pretty.ml
set GDSL_AVRSEM=
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-rreil-translator.ml
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-rreil-registermapping.ml
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-rreil-pretty.ml
set GDSL_AVRSEM=%GDSL_AVRSEM% specifications/avr/avr-liveness.ml
set GDSL_MIPS=
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips.ml
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips-asm.ml
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips-traverse.ml
set GDSL_MIPS=%GDSL_MIPS% specifications/mips/mips-pretty.ml
set GDSL_MIPSSEM=
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-rreil-translator.ml
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-rreil-registermapping.ml
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-rreil-pretty.ml
set GDSL_MIPSSEM=%GDSL_MIPSSEM% specifications/mips/mips-liveness.ml
set GDSL_RREIL=
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/fmap.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-examples.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-cif.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-pretty.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-liveness.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-forward-subst.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-cleanup.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-opt.ml
set GDSL_RREIL=%GDSL_RREIL% specifications/rreil/rreil-translator.ml
set GDSL_ARM7=
set GDSL_ARM7=%GDSL_ARM7% specifications/arm7/arm7.ml
set GDSL_ARM7=%GDSL_ARM7% specifications/arm7/arm7-pretty.ml
if NOT "%DECODER%"=="x86" goto NOT_x86
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_X86%
set OUT=gdsl-x86
:NOT_x86
if NOT "%DECODER%"=="x86-rreil" goto NOT_x86_rreil
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_X86% %GDSL_RREIL% %GDSL_X86SEM%
set OUT=gdsl-x86-rreil
:NOT_X86_rreil
if NOT "%DECODER%"=="avr" goto NOT_avr
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_AVR%
set OUT=gdsl-avr
:NOT_avr
if NOT "%DECODER%"=="avr-rreil" goto NOT_avr_rreil
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_AVR% %GDSL_RREIL% %GDSL_AVRSEM%
set OUT=gdsl-avr-rreil
:NOT_avr_rreil
if NOT "%DECODER%"=="mips" goto NOT_mips
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_MIPS%
set OUT=gdsl-mips
:NOT_mips
if NOT "%DECODER%"=="mips-rreil" goto NOT_mips_rreil
set SPEC=%GDSL_BASIS% %GDSL_ASM% %GDSL_MIPS% %GDSL_RREIL% %GDSL_MIPSSEM%
set OUT=gdsl-mips-rreil
:NOT_mips_rreil
if NOT "%DECODER%"=="arm7" goto NOT_arm7
set SPEC=%GDSL_BASIS% %GDSL_ARM7%
set OUT=gdsl-arm7
:NOT_arm7
echo Generating C code for %DECODER%.
gdslc.exe --target=C89 -o %OUT% %SPEC%
rem @echo off
if x%MSVC%x==xx (
echo Unable to compiler the generated decoder since the compiler cannot be found.
goto End
)
rem Find out where to get kernel32.lib and friends. It's somewhere under "Windows Kits"
rem which resides in "Program Files (x86)". This will probably break occasionally, but
rem it works for my machine. I couldn't find a reliably registry key. Feedback welcome.
for /f "usebackq tokens=*" %%d in (`dir /ad /b /s "C:\Program Files (x86)\Windows Kits" ^| find "\x86" ^| find /i "lib"`) do set SDKLIBPATH=%%d
if NOT defined SDKLIBPATH (
echo Cannot find SDK library directory. Use /sdklib switch to specify.
goto Error
)
set MSVCBARE=%MSVC:.exe=%
set LIB=%MSVCBARE:\bin\cl=\lib%;"%SDKLIBPATH%"
set INCLUDE=%MSVCBARE:\bin\cl=\include%
set CL=
echo Compiling %OUT%.c
%MSVC% /Od /Gd /nologo /Za /D WITHMAIN /TC %OUT%.c /link /OUT:"%OUTDIR%%OUT%-demo.exe"
goto End
:Error
exit /b 1
:End
......@@ -6,19 +6,31 @@ AM_INIT_AUTOMAKE([no-dependencies -Wall foreign no-define subdir-objects])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([LICENSE])
dnl the AM_PROG_AR macro only exists starting from 1.11.2
am_version=`automake --version | head -n 1 | sed -e 's/[[^0-9]*\([0-9][0-9.]*\)]/\1/g'`
m4_pattern_allow([AM_PROG_AR])
AS_VERSION_COMPARE([$am_version],[1.11.2],[],[AM_PROG_AR],[AM_PROG_AR])
AM_PROG_CC_C_O()
AM_PROG_AR()
AC_PROG_LN_S()
AC_PROG_LIBTOOL()
AC_PROG_INSTALL()
dnl check if the compiler understand C99
AC_PROG_CC_C99()
AC_ARG_ENABLE(msvc,[AS_HELP_STRING([--enable-msvc], [emit code for Microsoft Visual C compiler])])
AC_ARG_VAR(EXTRA_GDSL_FLAGS)
if test [x$ac_cv_prog_cc_c99 == "xno" -o x$enable_msvc == "xyes"]; then
EXTRA_GDSL_FLAGS="--target=C89";
fi
AC_ARG_VAR(SMLNJ)
AC_PATH_PROG(SMLNJ, sml, ["not-found"])
AC_ARG_VAR(MLTON)
AC_PATH_PROG(MLTON, mlton, ["not-found"])
if test [$SMLNJ == "not-found" -a $MLTON == "not-found"]; then
if test [x$SMLNJ == "xnot-found" -a x$MLTON == "xnot-found"]; then
echo "You must install either SML/NJ or mlton."
exit 1
fi
......@@ -26,20 +38,9 @@ fi
AM_CONDITIONAL([HAVE_MLTON],[test x$MLTON != "xnot-found"])
AC_ARG_VAR(MLULEX)
AC_PATH_PROG(MLULEX, ml-ulex, ["not-found"])
if test [$MLULEX == "not-found"]; then
echo "You must install SML/NJ (to get ml-ulex)."
exit 1
fi
AC_PATH_PROG(MLULEX, ml-ulex, ["ml-ulex not-found"])
AC_ARG_VAR(MLANTLR)
AC_PATH_PROG(MLANTLR, ml-antlr, ["not-found"])
if test [$MLANTLR == "not-found"]; then
echo "You must install SML/NJ (to get ml-antlr)."
exit 1
fi
AC_PATH_PROG(MLANTLR, ml-antlr, ["ml-antlr not-found"])
dnl define a variable that helps us to only build Linux-specific stuff on Linux
case "$host_os" in
......@@ -59,7 +60,7 @@ FRONTENDS="x86 x86-rreil avr avr-rreil mips mips-rreil arm7";
AC_ARG_WITH([frontend],
[AS_HELP_STRING(
[--with-frontend=frontend],
[one of: ]$FRONTENDS)],
[one of: x86 x86-rreil avr avr-rreil mips mips-rreil arm7])],
[], [with_frontend=all])
case $with_frontend in
......
This diff is collapsed.
This diff is collapsed.
......@@ -142,3 +142,4 @@ void
/* Exported tags of constructors. */
@tagnames@
......@@ -47,6 +47,13 @@ structure BasicControl : sig
(* the number of fields in a fixed record after which it is allocated
on the heap rather than passed by value *)
val boxThreshold : int Controls.control
datatype target_lang
= C99
| C89
(* language of the emitted code *)
val targetLanguage : target_lang Controls.control
(* wrap a 'pre -> 'post pass with a tracing diagnostic, controled by the
* "verbose" control.
......@@ -207,6 +214,19 @@ structure BasicControl : sig
default = 100
}
datatype target_lang
= C99
| C89
(* language of the emitted code *)
val targetLanguage : target_lang Controls.control = Controls.genControl {
name = "target",
pri = [0],
obscurity = 0,
help = "language of the emitted code (C89,C99)",
default = C99
}
val () = (
ControlRegistry.register topRegistry {
......
......@@ -127,7 +127,7 @@ structure Error :> sig
| Repair.FailureAt tok => ["syntax error at ", tok2str tok]
(* end case *))
in
addErr (es, SOME{file=sourceMap es,span=(pos,pos)}, String.concat msg)
addErr (es, SOME{file=sourceMap es,span=(pos,pos)}, String.concat msg ^ "\n")
end
(* add error messages to the error stream *)
......
......@@ -73,7 +73,7 @@ structure Main = struct
\ -t do not run the type checker\n\
\ --maxIter=n restrict fixpoint in type checker to n iterations\n\
\ --boxTheshold=n box fixed records with more than n fields\n\
\ -verbose verbose mode\n\
\ --target=lang language of output, one of C99,C89\n\
\"
fun processControl arg = let
......@@ -119,6 +119,12 @@ structure Main = struct
SOME num => Controls.set (BasicControl.boxThreshold, num)
| NONE => bad ("!* expected number for --boxThreshold\n")
and processTargetLanguage arg =
case String.implode (List.map Char.toUpper (String.explode arg)) of
"C99" => Controls.set (BasicControl.targetLanguage, BasicControl.C99)
| "C89" => Controls.set (BasicControl.targetLanguage, BasicControl.C89)
| _ => bad ("!* expected a language for --target\n")
and processArgs args =
case args of
arg :: args =>
......@@ -150,6 +156,9 @@ structure Main = struct
else
if String.isPrefix "--boxThreshold=" arg
then (processBoxThreshold (String.extract (arg,15,NONE)); processArgs args)
else
if String.isPrefix "--target=" arg
then (processTargetLanguage (String.extract (arg,9,NONE)); processArgs args)
else
case arg of
"-h" => usage ()
......
export decode-translate-block-optimized: (decoder-configuration, int, int) -> S sem_stmt_list <{} => {}>
export decode-translate-block-optimized-insncb: (decoder-configuration, int, int, insn_list_obj, (insn_list_obj, insndata) -> insn_list_obj) -> S opt-result <{} => {}>
export decode-translate-block-optimized: (decoder-configuration, int, rreil-configuration) -> S sem_stmt_list <{} => {}>
export decode-translate-block-optimized-insncb: (decoder-configuration, int, rreil-configuration, insn_list_obj, (insn_list_obj, insndata) -> insn_list_obj) -> S opt-result <{} => {}>
type sem_preservation =
SEM_PRESERVATION_EVERYWHERE
......@@ -39,24 +39,21 @@ type opt-result = {
rreil: sem_stmt_list
}
val decode-translate-block-optimized-insncb config limit pres insns-initv insn-append = do
# limit <- return (limit + 0);
# pres <- return (pres + 0);
val decode-translate-block-optimized-insncb config limit rreil-config insns-initv insn-append = do
update @{insns=insns-initv};
rreil <- case pres of
0: decode-translate-block-optimized-insncb-inner config limit SEM_PRESERVATION_EVERYWHERE insn-append
| 1: decode-translate-block-optimized-insncb-inner config limit SEM_PRESERVATION_BLOCK insn-append
| 2: decode-translate-block-optimized-insncb-inner config limit SEM_PRESERVATION_CONTEXT insn-append
rreil <- case rreil-config of
'00.': decode-translate-block-optimized-insncb-inner config limit SEM_PRESERVATION_EVERYWHERE insn-append
| '01.': decode-translate-block-optimized-insncb-inner config limit SEM_PRESERVATION_BLOCK insn-append
| '1..': decode-translate-block-optimized-insncb-inner config limit SEM_PRESERVATION_CONTEXT insn-append
end;
insns <- query $insns;
return {rreil=rreil, insns=insns}
end
val decode-translate-block-optimized config limit pres = let
val decode-translate-block-optimized config limit rreil-config = let
val default-append a b = a
in do
result <- decode-translate-block-optimized-insncb config limit pres INSN_LIST_OBJ default-append;
result <- decode-translate-block-optimized-insncb config limit rreil-config INSN_LIST_OBJ default-append;
return result.rreil
end end
......
......@@ -4,6 +4,15 @@ export decode-translate-block-insns: (decoder-configuration, int, (insn_list_obj
export decode-translate-super-block: (decoder-configuration, int) -> S translate-result <{insns: insn_list_obj} => {insns: insn_list_obj}>
export select_ins_count: S int <{ins_count: int} => {ins_count: int}>
export succ-pretty: (stmts_option, string) -> rope
export rreil-config : configuration[vec=rreil-configuration]
type rreil-configuration = |3|
val rreil-config =
conf '001' "block" "translate a basic block at a time" &*
conf '010' "liveness" "remove dead assignments" &*
conf '100' "inter-bb" "perform inter-basic block liveness analysis"
val insn-append-default a b = a
......
......@@ -243,12 +243,12 @@ val show/segment s =
end
end
val show/scale s =
val show/scale s arg =
case s of
'00': ""
| '01': "2*"
| '10': "4*"
| '11': "8*"
'00': arg
| '01': "2*" +++ "(" +++ arg +++ ")"
| '10': "4*" +++ "(" +++ arg +++ ")"
| '11': "8*" +++ "(" +++ arg +++ ")"
end
val show/operand ext op =
......@@ -263,20 +263,26 @@ val show/operand ext op =
| IMM64 x: show-int (case ext of '0': zx x.imm | '1': sx x.imm end)
| REG x: show/x86-register x
| MEM x: show/memsz x.sz -++ show/segment x.segment +++ "[" +++ show/operand '1' x.opnd +++ "]"
| X86_SUM x: show/operand ext x.a +++ "+" +++ show/operand ext x.b
| X86_SCALE x: show/scale x.imm +++ show/operand ext x.opnd
| X86_SUM x: show/operand ext x.a +++ (if ext then case x.b of
IMM8 c: (if sx c.imm<0 then "" else "+") +++ show/operand ext x.b
| IMM16 c: (if sx c.imm<0 then "" else "+") +++ show/operand ext x.b
| IMM32 c: (if sx c.imm<0 then "" else "+") +++ show/operand ext x.b
| IMM64 c: (if sx c.imm<0 then "" else "+") +++ show/operand ext x.b
| _ : "+" +++ show/operand ext x.b
end else "+" +++ show/operand ext x.b)
| X86_SCALE x: show/scale x.imm (show/operand ext x.opnd)
end
val show/flowoperand op =
case op of
REL8 x: "(IP + " +++ show-int (sx x) +++ ")"
| REL16 x: "(IP + " +++ show-int (sx x) +++ ")"
| REL32 x: "(IP + " +++ show-int (sx x) +++ ")"
| REL64 x: "(IP + " +++ show-int (sx x) +++ ")"
REL8 x: "IP" +++ (if sx x<0 then "" else "+") +++ show-int (sx x)
| REL16 x: "IP" +++ (if sx x<0 then "" else "+") +++ show-int (sx x)
| REL32 x: "IP" +++ (if sx x<0 then "" else "+") +++ show-int (sx x)
| REL64 x: "IP" +++ (if sx x<0 then "" else "+") +++ show-int (sx x)
| PTR16/16 x: "[16/16: " +++ show-int (sx x) +++ "]"
| PTR16/32 x: "[16/32: " +++ show-int (sx x) +++ "]"
| NEARABS x: show/operand '1' x
| FARABS x: show/operand '1' x
| NEARABS x: show/operand '0' x
| FARABS x: show/operand '0' x
end
val show/instruction insn = let
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment