mcmodel=
Target RejectNegative Joined Enum(or1k_cmodel_type) Var(or1k_code_model) Init(CMODEL_SMALL)
Specify the code model used for accessing memory addresses. Specifying large
-enables generating binaries with large global offset tables. By default the
-value is small.
+enables generating binaries with large global offset tables and calling
+functions anywhere in an executable. By default the value is small.
Enum
Name(or1k_cmodel_type) Type(enum or1k_cmodel_type)
(match_test "TARGET_ROR"))))
(define_predicate "call_insn_operand"
- (ior (match_code "symbol_ref")
+ (ior (and (match_code "symbol_ref")
+ (match_test "!TARGET_CMODEL_LARGE"))
(match_operand 0 "register_operand")))
(define_predicate "high_operand"
@opindex mcmodel=
@opindex mcmodel=small
@item -mcmodel=small
-Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
-the default model.
+Generate OpenRISC code for the small model: The GOT is limited to 64k and
+function call jumps are limited to 64M offsets. This is the default model.
@opindex mcmodel=large
@item -mcmodel=large
-Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
+Generate OpenRISC code for the large model: The GOT may grow up to 4G in size
+and function call jumps can target the full 4G address space.
@end table
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcmodel=large" } */
+
+/* Generate local and global function calls. */
+
+extern int geti (void);
+
+__attribute__ ((noinline)) int
+calc (int a, int b)
+{
+ return a * b + 255;
+}
+
+int
+main (void)
+{
+ return geti () + calc (3, 4);
+}
+
+/* Ensure the 2 calls use register not immediate jumps. */
+/* { dg-final { scan-assembler-times "l.movhi\\s+" 2 } } */
+/* { dg-final { scan-assembler-times "l.jalr\\s+" 2 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fPIC -mcmodel=large" } */
+
+/* Generate references to the GOT. */
+
+extern int geti (void);
+extern int j;
+
+int
+calc (int a)
+{
+ return a * j + geti ();
+}
+
+/* Ensure the 2 references use gotha relocations and that the function call does
+ not use an immediate jump instruction. */
+/* { dg-final { scan-assembler-times "gotha" 2 } } */
+/* { dg-final { scan-assembler "l.jalr\\s+" } } */