From 55f2117ceb78ac9ceb2ff272da48c0a520745012 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 11 Nov 2011 12:22:49 +0100 Subject: [PATCH] pet: use isl for argument parsing Signed-off-by: Sven Verdoolaege --- Makefile.am | 2 +- main.cc => main.c | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) rename main.cc => main.c (75%) diff --git a/Makefile.am b/Makefile.am index c77394c..0f5f675 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,7 @@ pet_LDFLAGS = $(AM_LDFLAGS) @LIBYAML_LDFLAGS@ pet_SOURCES = \ emit.c \ scop_yaml.h \ - main.cc + main.c pet_LDADD = libpet.la \ -lclangFrontend -lclangParse -lclangSema -lclangAnalysis \ -lclangAST -lclangLex -lclangBasic -lclangDriver -lclangSerialization \ diff --git a/main.cc b/main.c similarity index 75% rename from main.cc rename to main.c index 8064835..f411d48 100644 --- a/main.cc +++ b/main.c @@ -31,35 +31,36 @@ * Leiden University. */ -#include -#include - +#include #include #include "options.h" #include "scop.h" #include "scop_yaml.h" -using namespace std; +struct options { + struct pet_options *pet; + char *input; +}; + +ISL_ARGS_START(struct options, options_args) +ISL_ARG_CHILD(struct options, pet, NULL, &pet_options_args, NULL) +ISL_ARG_ARG(struct options, input, "input", NULL) +ISL_ARGS_END -static llvm::cl::opt InputFilename(llvm::cl::Positional, - llvm::cl::Required, llvm::cl::desc("")); -static llvm::cl::opt AutoDetect("autodetect", - llvm::cl::desc("Autodetect scops")); +ISL_ARG_DEF(options, struct options, options_args) int main(int argc, char *argv[]) { isl_ctx *ctx; - pet_scop *scop; - pet_options *options; - - options = pet_options_new_with_defaults(); - ctx = isl_ctx_alloc_with_options(&pet_options_args, options); + struct pet_scop *scop; + struct options *options; - llvm::cl::ParseCommandLineOptions(argc, argv); + options = options_new_with_defaults(); + ctx = isl_ctx_alloc_with_options(&options_args, options); + argc = options_parse(options, argc, argv, ISL_ARG_ALL); - options->autodetect = AutoDetect; - scop = pet_scop_extract_from_C_source(ctx, InputFilename.c_str(), NULL); + scop = pet_scop_extract_from_C_source(ctx, options->input, NULL); if (scop) pet_scop_emit(stdout, scop); -- 2.11.4.GIT