Exemplo n.º 1
0
static LLVMTargetMachineRef make_machine(pass_opt_t* opt)
{
  LLVMTargetRef target;
  char* err;

  if(LLVMGetTargetFromTriple(opt->triple, &target, &err) != 0)
  {
    errorf(opt->check.errors, NULL, "couldn't create target: %s", err);
    LLVMDisposeMessage(err);
    return NULL;
  }

  LLVMCodeGenOptLevel opt_level =
    opt->release ? LLVMCodeGenLevelAggressive : LLVMCodeGenLevelNone;

  LLVMRelocMode reloc =
    (opt->pic || opt->library) ? LLVMRelocPIC : LLVMRelocDefault;

  LLVMTargetMachineRef machine = LLVMCreateTargetMachine(target, opt->triple,
    opt->cpu, opt->features, opt_level, reloc, LLVMCodeModelDefault);

  if(machine == NULL)
  {
    errorf(opt->check.errors, NULL, "couldn't create target machine");
    return NULL;
  }

  return machine;
}
Exemplo n.º 2
0
/* string -> Target.t */
CAMLprim LLVMTargetRef llvm_target_by_triple(value Triple) {
  LLVMTargetRef T;
  char *Error;

  if(LLVMGetTargetFromTriple(String_val(Triple), &T, &Error))
    llvm_raise(*caml_named_value("Llvm_target.Error"), Error);

  return T;
}
Exemplo n.º 3
0
/* string -> Target.t */
CAMLprim LLVMTargetRef llvm_target_by_triple(value Triple) {
  LLVMTargetRef T;
  char *Error;

  if(LLVMGetTargetFromTriple(String_val(Triple), &T, &Error))
    llvm_raise(llvm_target_error_exn, Error);

  return T;
}
Exemplo n.º 4
0
LLVMTargetRef ac_get_llvm_target(const char *triple)
{
	LLVMTargetRef target = NULL;
	char *err_message = NULL;

	call_once(&ac_init_llvm_target_once_flag, ac_init_llvm_target);

	if (LLVMGetTargetFromTriple(triple, &target, &err_message)) {
		fprintf(stderr, "Cannot find target for triple %s ", triple);
		if (err_message) {
			fprintf(stderr, "%s\n", err_message);
		}
		LLVMDisposeMessage(err_message);
		return NULL;
	}
	return target;
}
Exemplo n.º 5
0
LLVMTargetRef radeon_llvm_get_r600_target(const char *triple)
{
	LLVMTargetRef target = NULL;
	char *err_message = NULL;

	init_r600_target();

	if (LLVMGetTargetFromTriple(triple, &target, &err_message)) {
		fprintf(stderr, "Cannot find target for triple %s ", triple);
		if (err_message) {
			fprintf(stderr, "%s\n", err_message);
		}
		LLVMDisposeMessage(err_message);
		return NULL;
	}
	return target;
}