begin work on audit-codegen

This commit is contained in:
Joshua Warner 2013-02-18 07:50:37 -07:00 committed by Joshua Warner
parent 24c0fab9bf
commit 46029939d3
4 changed files with 123 additions and 36 deletions

View File

@ -994,6 +994,8 @@ all-assembler-sources = \
native-assembler-sources = $($(target-asm)-assembler-sources)
native-assembler-objects = $($(target-asm)-assembler-objects)
audit-codegen-sources = $(wildcard $(src)/tools/audit-codegen/*.cpp)
all-codegen-target-sources = \
$(compiler-sources) \
$(native-assembler-sources)
@ -1154,6 +1156,7 @@ dynamic-library = $(build)/$(so-prefix)jvm$(so-suffix)
executable-dynamic = $(build)/$(name)-dynamic$(exe-suffix)
unittest-executable = $(build)/$(name)-unittest${exe-suffix}
audit-codegen-executable = $(build)/audit-codegen${exe-suffix}
ifneq ($(classpath),avian)
# Assembler, ConstantPool, and Stream are not technically needed for a
@ -1304,6 +1307,14 @@ else
ssh -p$(remote-test-port) $(remote-test-user)@$(remote-test-host) sh "$(remote-test-dir)/$(platform)-$(arch)$(options)/run-tests.sh"
endif
PHONY: audit-baseline
audit-baseline: $(audit-codegen-executable)
$(<) -output $(build)/codegen-audit-output/baseline.o -format macho
PHONY: audit
audit: $(audit-codegen-executable)
$(<) -output $(build)/codegen-audit-output/baseline.o -format macho
.PHONY: tarball
tarball:
@echo "creating build/avian-$(version).tar.bz2"
@ -1412,6 +1423,9 @@ endif
$(unittest-objects): $(build)/unittest/%.o: $(unittest)/%.cpp $(vm-depends) $(unittest-depends)
$(compile-unittest-object)
$(build)/tools/audit-codegen/main.o: $(build)/%.o: $(src)/%.cpp $(vm-depends)
$(compile-object)
$(test-cpp-objects): $(test-build)/%.o: $(test)/%.cpp $(vm-depends)
$(compile-object)
@ -1590,43 +1604,53 @@ ifeq ($(process),interpret)
unittest-executable-objects += $(all-codegen-target-objects)
endif
$(executable): $(executable-objects)
@echo "linking $(@)"
ifeq ($(platform),windows)
ifdef ms_cl_compiler
$(ld) $(lflags) $(executable-objects) -out:$(@) \
-debug -PDB:$(subst $(exe-suffix),.pdb,$(@)) $(manifest-flags)
ifdef mt
$(mt) -nologo -manifest $(@).manifest -outputresource:"$(@);1"
endif
else
$(dlltool) -z $(@).def $(executable-objects)
$(dlltool) -d $(@).def -e $(@).exp
$(ld) $(@).exp $(executable-objects) $(lflags) -o $(@)
endif
else
$(ld) $(executable-objects) $(rdynamic) $(lflags) $(bootimage-lflags) -o $(@)
endif
$(strip) $(strip-all) $(@)
audit-codegen-objects = $(call cpp-objects,$(audit-codegen-sources),$(src),$(build))
audit-codegen-executable-objects = $(audit-codegen-objects) $(vm-objects) $(build)/util/arg-parser.o
.PHONY: print
print:
@echo $(audit-codegen-objects)
# apparently, make does poorly with ifs inside of defines, and indented defines.
# I suggest re-indenting the following before making edits (and unindenting afterwards):
ifneq ($(platform),windows)
define link-executable
@echo linking $(@)
$(ld) $(^) $(rdynamic) $(lflags) $(bootimage-lflags) -o $(@)
endef
else
ifdef ms_cl_compiler
ifdef mt
define link-executable
@echo linking $(@)
$(ld) $(lflags) $(^) -out:$(@) \
-debug -PDB:$(subst $(exe-suffix),.pdb,$(@)) $(manifest-flags)
$(mt) -nologo -manifest $(@).manifest -outputresource:"$(@);1"
endef
else
define link-executable
@echo linking $(@)
$(mt) -nologo -manifest $(@).manifest -outputresource:"$(@);1"
endef
endif
else
define link-executable
@echo linking $(@)
$(dlltool) -z $(@).def $(^)
$(dlltool) -d $(@).def -e $(@).exp
$(ld) $(@).exp $(^) $(lflags) -o $(@)
endef
endif
endif
$(executable): $(executable-objects)
$(link-executable)
$(unittest-executable): $(unittest-executable-objects)
@echo "linking $(@)"
ifeq ($(platform),windows)
ifdef ms_cl_compiler
$(ld) $(lflags) $(unittest-executable-objects) -out:$(@) \
-debug -PDB:$(subst $(exe-suffix),.pdb,$(@)) $(manifest-flags)
ifdef mt
$(mt) -nologo -manifest $(@).manifest -outputresource:"$(@);1"
endif
else
$(dlltool) -z $(@).def $(unittest-executable-objects)
$(dlltool) -d $(@).def -e $(@).exp
$(ld) $(@).exp $(unittest-executable-objects) $(lflags) -o $(@)
endif
else
$(ld) $(unittest-executable-objects) $(rdynamic) $(lflags) $(bootimage-lflags) -o $(@)
endif
$(link-executable)
$(audit-codegen-executable): $(audit-codegen-executable-objects)
$(link-executable)
$(bootimage-generator): $(bootimage-generator-objects)
echo building $(bootimage-generator) arch=$(build-arch) platform=$(bootimage-platform)

View File

@ -0,0 +1,63 @@
/* Copyright (c) 2008-2012, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
#include "system.h"
#include "util/arg-parser.h"
#include "codegen/lir.h"
#include "codegen/assembler.h"
#include "codegen/targets.h"
// since we aren't linking against libstdc++, we must implement this
// ourselves:
extern "C" void __cxa_pure_virtual(void) { abort(); }
using namespace avian::codegen;
using namespace avian::util;
void generateCode(Assembler::Architecture* arch) {
for()
}
class Arguments {
public:
const char* output;
const char* outputFormat;
Arguments(int argc, char** argv) {
ArgParser parser;
Arg out(parser, true, "output", "<output object file>");
Arg format(parser, true, "format", "<format of output object file>");
if(!parser.parse(argc, argv)) {
exit(1);
}
output = out.value;
outputFormat = format.value;
// TODO: sanitize format values
}
};
int main(int argc, char** argv) {
Arguments args(argc, argv);
vm::System* s = vm::makeSystem(0);
Assembler::Architecture* arch = makeArchitectureNative(s, true);
arch->acquire();
generateCode(arch);
arch->release();
s->dispose();
return 0;
}

View File

@ -31,7 +31,7 @@ ArgParser::ArgParser():
first(0),
last(&first) {}
bool ArgParser::parse(int ac, const char** av) {
bool ArgParser::parse(int ac, const char* const* av) {
Arg* state = 0;
for(int i = 1; i < ac; i++) {

View File

@ -23,7 +23,7 @@ public:
ArgParser();
bool parse(int ac, const char** av);
bool parse(int ac, const char* const* av);
void printUsage(const char* exe);
};