Skip to content

Commit 87e387a

Browse files
committed
openrisc: Add gcc machine instruction flag configuration
OpenRISC GCC supports flags to enable the backend to output instructions if they are supported by a target processor. This patch adds configuration flags to enable configuring these flags to tune the kernel for a particular CPU configuration. In the future we could also enable all of these flags by default and provide instruction emulation in the kernel to make these choices easier for users but this is what we provide for now. Signed-off-by: Stafford Horne <[email protected]>
1 parent 635267b commit 87e387a

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

arch/openrisc/Kconfig

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,59 @@ config OPENRISC_HAVE_INST_DIV
114114
default y
115115
help
116116
Select this if your implementation has a hardware divide instruction
117+
118+
config OPENRISC_HAVE_INST_CMOV
119+
bool "Have instruction l.cmov for conditional move"
120+
default n
121+
help
122+
This config enables gcc to generate l.cmov instructions when compiling
123+
the kernel which in general will improve performance and reduce the
124+
binary size.
125+
126+
Select this if your implementation has support for the Class II
127+
l.cmov conistional move instruction.
128+
129+
Say N if you are unsure.
130+
131+
config OPENRISC_HAVE_INST_ROR
132+
bool "Have instruction l.ror for rotate right"
133+
default n
134+
help
135+
This config enables gcc to generate l.ror instructions when compiling
136+
the kernel which in general will improve performance and reduce the
137+
binary size.
138+
139+
Select this if your implementation has support for the Class II
140+
l.ror rotate right instruction.
141+
142+
Say N if you are unsure.
143+
144+
config OPENRISC_HAVE_INST_RORI
145+
bool "Have instruction l.rori for rotate right with immediate"
146+
default n
147+
help
148+
This config enables gcc to generate l.rori instructions when compiling
149+
the kernel which in general will improve performance and reduce the
150+
binary size.
151+
152+
Select this if your implementation has support for the Class II
153+
l.rori rotate right with immediate instruction.
154+
155+
Say N if you are unsure.
156+
157+
config OPENRISC_HAVE_INST_SEXT
158+
bool "Have instructions l.ext* for sign extension"
159+
default n
160+
help
161+
This config enables gcc to generate l.ext* instructions when compiling
162+
the kernel which in general will improve performance and reduce the
163+
binary size.
164+
165+
Select this if your implementation has support for the Class II
166+
l.exths, l.extbs, l.exthz and l.extbz size extend instructions.
167+
168+
Say N if you are unsure.
169+
117170
endmenu
118171

119172
config NR_CPUS

arch/openrisc/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S
2121
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
2222

2323
KBUILD_CFLAGS += -pipe -ffixed-r10 -D__linux__
24+
KBUILD_CFLAGS += -msfimm -mshftimm
2425

2526
all: vmlinux.bin
2627

@@ -38,6 +39,22 @@ else
3839
KBUILD_CFLAGS += $(call cc-option,-msoft-div)
3940
endif
4041

42+
ifeq ($(CONFIG_OPENRISC_HAVE_INST_CMOV),y)
43+
KBUILD_CFLAGS += $(call cc-option,-mcmov)
44+
endif
45+
46+
ifeq ($(CONFIG_OPENRISC_HAVE_INST_ROR),y)
47+
KBUILD_CFLAGS += $(call cc-option,-mror)
48+
endif
49+
50+
ifeq ($(CONFIG_OPENRISC_HAVE_INST_RORI),y)
51+
KBUILD_CFLAGS += $(call cc-option,-mrori)
52+
endif
53+
54+
ifeq ($(CONFIG_OPENRISC_HAVE_INST_SEXT),y)
55+
KBUILD_CFLAGS += $(call cc-option,-msext)
56+
endif
57+
4158
head-y := arch/openrisc/kernel/head.o
4259

4360
libs-y += $(LIBGCC)

0 commit comments

Comments
 (0)