comparison gen/main.cpp @ 1021:d1ec9ff0e9ba

Implemented basic -m32 and -m64 options.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 01 Mar 2009 22:27:03 +0100
parents 55051098d9fc
children abfe71f5b911
comparison
equal deleted inserted replaced
1020:474d7dd54d43 1021:d1ec9ff0e9ba
335 fatal(); 335 fatal();
336 } 336 }
337 } 337 }
338 338
339 // create a proper target 339 // create a proper target
340
341 // check -m32/64 sanity
342 if (m32bits && m64bits)
343 error("cannot use both -m32 and -m64 options");
344 else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty()))
345 error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches");
346 if (global.errors)
347 fatal();
348
340 llvm::Module mod("dummy"); 349 llvm::Module mod("dummy");
350
351 // override triple if needed
352 const char* defaultTriple = DEFAULT_TARGET_TRIPLE;
353 if ((sizeof(void*) == 4 && m64bits) || (sizeof(void*) == 8 && m32bits))
354 {
355 defaultTriple = DEFAULT_ALT_TARGET_TRIPLE;
356 }
341 357
342 // did the user override the target triple? 358 // did the user override the target triple?
343 if (mTargetTriple.empty()) 359 if (mTargetTriple.empty())
344 { 360 {
345 if (mArch != 0) 361 if (mArch != 0)
346 { 362 {
347 error("you must specify a target triple as well with -mtriple when using the -march option"); 363 error("you must specify a target triple as well with -mtriple when using the -march option");
348 fatal(); 364 fatal();
349 } 365 }
350 global.params.targetTriple = DEFAULT_TARGET_TRIPLE; 366 global.params.targetTriple = defaultTriple;
351 } 367 }
352 else 368 else
353 { 369 {
354 global.params.targetTriple = mTargetTriple.c_str(); 370 global.params.targetTriple = mTargetTriple.c_str();
355 } 371 }