aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/gogo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go/gofrontend/gogo.cc')
-rw-r--r--gcc/go/gofrontend/gogo.cc45
1 files changed, 26 insertions, 19 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index a3afdcb..20c3420 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -4146,25 +4146,8 @@ Build_recover_thunks::can_recover_arg(Location location)
{
static Named_object* builtin_return_address;
if (builtin_return_address == NULL)
- {
- const Location bloc = Linemap::predeclared_location();
-
- Typed_identifier_list* param_types = new Typed_identifier_list();
- Type* uint_type = Type::lookup_integer_type("uint");
- param_types->push_back(Typed_identifier("l", uint_type, bloc));
-
- Typed_identifier_list* return_types = new Typed_identifier_list();
- Type* voidptr_type = Type::make_pointer_type(Type::make_void_type());
- return_types->push_back(Typed_identifier("", voidptr_type, bloc));
-
- Function_type* fntype = Type::make_function_type(NULL, param_types,
- return_types, bloc);
- builtin_return_address =
- Named_object::make_function_declaration("__builtin_return_address",
- NULL, fntype, bloc);
- const char* n = "__builtin_return_address";
- builtin_return_address->func_declaration_value()->set_asm_name(n);
- }
+ builtin_return_address =
+ Gogo::declare_builtin_rf_address("__builtin_return_address");
static Named_object* can_recover;
if (can_recover == NULL)
@@ -4216,6 +4199,30 @@ Gogo::build_recover_thunks()
this->traverse(&build_recover_thunks);
}
+// Return a declaration for __builtin_return_address or
+// __builtin_frame_address.
+
+Named_object*
+Gogo::declare_builtin_rf_address(const char* name)
+{
+ const Location bloc = Linemap::predeclared_location();
+
+ Typed_identifier_list* param_types = new Typed_identifier_list();
+ Type* uint32_type = Type::lookup_integer_type("uint32");
+ param_types->push_back(Typed_identifier("l", uint32_type, bloc));
+
+ Typed_identifier_list* return_types = new Typed_identifier_list();
+ Type* voidptr_type = Type::make_pointer_type(Type::make_void_type());
+ return_types->push_back(Typed_identifier("", voidptr_type, bloc));
+
+ Function_type* fntype = Type::make_function_type(NULL, param_types,
+ return_types, bloc);
+ Named_object* ret = Named_object::make_function_declaration(name, NULL,
+ fntype, bloc);
+ ret->func_declaration_value()->set_asm_name(name);
+ return ret;
+}
+
// Build a call to the runtime error function.
Expression*