Yes. I got my agent after I had a contract offer for a M/M erotic romance space opera from one of the bigger erotic romance digital-first publishers. I needed an agent because of possible contract issues with other work. Her help was invaluable.
She will be representing both my future erotic romance books and mainstream fantasy. Why? Because M/M is heating up in mainstream markets: I know of at least two M/M authors - with explicit content - who have had agented deals with major publishers in the last year.
That said, which agent you get is important. When I was querying that space opera, all three of the qualified agencies said no. I did not bother with agents I did not consider qualified to handle both of my genres. Track record is as critical as sympathy toward genres. (My first agent, years back, is not comfortable with my direction toward M/M.) I know of one 'agent' who, while a great supporter of the M/M genre, did not really help several clients.
Many M/M authors do just fine without an agent, provided they pay attention to contract details. Mine was an odd case.